0 votes
730 views
in Wordpress by (730 points)
Why do my wordpress get_current_user_id() returns 0?

1 Answer

0 votes
by
You need to init before that.

add_action('init', 'my_user_id_Function');

function my_user_id_Function()
{
  return get_current_user_id();
}

echo my_user_id_Function();
by
Thanks... yay that saved my day!

Related questions

+2 votes
2 answers 5.9k views
0 votes
1 answer 419 views
asked Aug 25, 2016 in Wordpress by Sita
0 votes
1 answer 54 views
+1 vote
1 answer 547 views
asked Oct 14, 2016 in Wordpress by Justin
+2 votes
1 answer 741 views
0 votes
1 answer 667 views
...