0 votes
1.8k 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 6.7k views
0 votes
1 answer 481 views
asked Aug 25, 2016 in Wordpress by Sita
0 votes
1 answer 950 views
+1 vote
1 answer 634 views
asked Oct 14, 2016 in Wordpress by Justin
+2 votes
1 answer 792 views
0 votes
1 answer 1.9k views
...