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

1 Answer

0 votes
answered 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();

Related questions

+2 votes
2 answers 5.8k views
0 votes
1 answer 409 views
asked Aug 25, 2016 in Wordpress by Sita
+1 vote
1 answer 537 views
asked Oct 14, 2016 in Wordpress by Justin
+2 votes
1 answer 728 views
0 votes
1 answer 495 views
0 votes
0 answers 346 views
asked Dec 6, 2016 in Laravel by Jinu
...