0 votes
5.0k views
in Wordpress by (1.3k 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 9.7k views
0 votes
1 answer 1.3k views
asked Aug 25, 2016 in Wordpress by Sita
0 votes
1 answer 2.5k views
+1 vote
1 answer 1.8k views
asked Oct 14, 2016 in Wordpress by Justin
+2 votes
1 answer 1.8k views
0 votes
1 answer 4.1k views
...