0 votes
1.2k 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.3k views
0 votes
1 answer 461 views
asked Aug 25, 2016 in Wordpress by Sita
0 votes
1 answer 490 views
+1 vote
1 answer 607 views
asked Oct 14, 2016 in Wordpress by Justin
+2 votes
1 answer 774 views
0 votes
1 answer 1.2k views
...