Login
Remember
Register
PHPOnlineSupport
Questions
Unanswered
Tags
Categories
Ask a Question
Ask a Question
wp get_current_user_id() returns 0
0
votes
5.0k
views
asked
Nov 8, 2018
in
Wordpress
by
mithun
(
1.3k
points)
Why do my wordpress get_current_user_id() returns 0?
wp
Your comment on this question:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
1
Answer
0
votes
answered
Nov 8, 2018
by
wc_champ
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();
commented
Nov 14, 2019
by
Michael
Thanks... yay that saved my day!
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
Related questions
+2
votes
2
answers
9.7k
views
Migrate posts from an old wp to a new wp site
asked
Sep 2, 2016
in
Wordpress
by
Jerry
wordpress
wp
migrate
post
0
votes
1
answer
1.3k
views
WP backend slowness
asked
Aug 25, 2016
in
Wordpress
by
Sita
wp
wordpress
admin
slow
0
votes
1
answer
2.5k
views
Adblocker blocking WP blog images
asked
Nov 15, 2019
in
General
by
David
adblocker
wp
wordpress
+1
vote
1
answer
1.8k
views
Wordpress theme with Magento
asked
Oct 14, 2016
in
Wordpress
by
Justin
wordpress
wp
magento
+2
votes
1
answer
1.8k
views
User accounts sync between Magento and Wordpress
asked
Jun 6, 2016
in
Wordpress
by
Julius
magento
wordpress
wp
sync
0
votes
1
answer
4.1k
views
Fatal error: Call to undefined function wp_get_current_user() in
asked
Nov 2, 2018
in
Plugins
by
mithun
(
1.3k
points)
wp
wordpress
plugin
All categories
General
(56)
CMS
(21)
Wordpress
(19)
Plugins
(5)
Themes
(2)
Drupal
(1)
Joomla
(1)
Frameworks
(21)
eCommerce
(58)
IOT - Internet Of Things
(10)
Javascript
(10)
Databases
(5)
Categories
All categories
General
(56)
CMS
(21)
Wordpress
(19)
Plugins
(5)
Themes
(2)
Drupal
(1)
Joomla
(1)
Frameworks
(21)
eCommerce
(58)
IOT - Internet Of Things
(10)
Javascript
(10)
Databases
(5)
Most popular tags
magento
php
wordpress
wp
laravel
category
database
module
product
arduino
kohana
js
jquery
admin
date
url
sing
birds
json
javascript
cms
cache
error
configurable
love
mac
xbee
serial1
serial
seo
encrypt
recaptha
phalcon
truncate
fishpig
include
backend
function
email
plugin
post
arduinojson
popup
mongodb
security
migrate
editor
decrypt
python
iot
map
shipping
password
core
log
mage
pear
string
replace
extension
import
php7
form
order
day
google
image
youtube
https
http
customer
syntaxerror
datatables
nested
x-ctu
xctu
pan-id
mesh
coordinator
esp
baud
esp8266
esp32
path-issue
site-links
adblocker
qr-code
barcode
samsung
newsletter
feed
auto-numbering-column
datatable
admin-bar
adminbar
toolbar
address16
address64
301
302
...