0 votes
4.6k 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.1k views
0 votes
1 answer 1.0k views
asked Aug 25, 2016 in Wordpress by Sita
0 votes
1 answer 2.3k views
+1 vote
1 answer 1.4k views
asked Oct 14, 2016 in Wordpress by Justin
+2 votes
1 answer 1.5k views
0 votes
1 answer 3.7k views
...