wp_get_current_user() function returns 0 always
-
Hi,
i have recently upgrade the wordpress to multisite in my clients site..
for your reference here is the link…
realestate.nyasatimes.comeven after i logged as admin, current user always shows as 0.. i dont know where the issue was.. was googling for last 6 hours and tried some thing nothing helped me π
so finally i am here to seek your help.. your time to read my question is much appreciated. pls help me to cross this issue..
here is .htaccess file for your reference
RewriteEngine On #redirect to www for the main site RewriteCond %{HTTP_HOST} ^nyasatimes\.com RewriteRule ^ http://www.nyasatimes.com/%{REQUEST_URI} [L,R=301] RewriteBase / RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule . index.php [L]
-
even after i logged as admin, current user always shows as 0.
Shows as 0 where?
<?php global $user; $user = wp_get_current_user(); echo "<h1> current user id is .. ".$user->ID."</h1>"; ?>above piece of code returns 0.. that meant it assumes no user logged into the site… but i can able to access http://site.com/wp-admin/
Hrm. Why not use http://codex.ww.wp.xz.cn/Function_Reference/is_user_logged_in
π even this does not helps.. get current blog returns correct values..
is there any thing specially needs to be done in admin panel
(install plugin or change values in config) …i am not sure how sign up and login differ from normal wordpress… can some one share me if you know ???
They shouldn’t be, unless you’re using domain mapping.
thank you so much for your response till now.. much appreciated…
but i have no clue why wp_get_current_user() returns nothing when i am logged in admin panel. i am not using domain mapping.. just using sub domains created in wordpress admin panel.
its breaking my head.. i dont know how to start my debugging to fix this issue.
on my further research.. i am seeing this error in apache log
[Tue Sep 27 19:14:56 2011] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function is_home() in /var/www/***********/wp-content/themes/real_state_nyasatimes/library/includes/search.php on line 3 [Tue Sep 27 19:16:32 2011] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function _e() in /var/www/***********/wp-content/themes/real_state_nyasatimes/library/includes/admin_notification.php on line 20 [Tue Sep 27 19:18:08 2011] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function bloginfo() in /var/www/***********/wp-content/themes/real_state_nyasatimes/library/includes/image_uploader.php on line 10 [Tue Sep 27 19:19:44 2011] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function get_header() in /var/www/***********/wp-content/themes/real_state_nyasatimes/library/includes/return.php on line 1 [Tue Sep 27 19:21:21 2011] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function get_header() in /var/www/***********/wp-content/themes/real_state_nyasatimes/library/includes/agents.php on line 1 [Tue Sep 27 19:24:34 2011] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function get_header() in /var/www/***********/wp-content/themes/real_state_nyasatimes/library/includes/success.php on line 1 [Tue Sep 27 19:26:10 2011] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function bloginfo() in /var/www/***********/wp-content/themes/real_state_nyasatimes/library/includes/property_listing.php on line 1 [Tue Sep 27 19:27:46 2011] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function get_option() in /var/www/***********/wp-content/themes/real_state_nyasatimes/library/includes/blog_listing.php on line 2 [Tue Sep 27 19:29:22 2011] [error] [client 127.0.0.1] PHP Notice: Undefined index: page in /var/www/***********/wp-content/themes/real_state_nyasatimes/library/includes/reg_frm.php on line 3I was trying to reproduce this and couldn’t but … based on these errors, I would start with switching themes for a moment.
this is very strange.. i tried to replace all wordpress files except wpconfig and wp-content and still that does not help me…
i have installed QA theme in test site Still that has same error..
[Wed Sep 28 03:29:11 2011] [error] [client 127.0.0.1] PHP Warning: Missing argument 7 for _cat_rows1(), called in /var/www/*****************/wp-content/themes/real_state_nyasatimes/library/functions/custom_functions.php on line 431 and defined in /var/www/*****************/wp-content/themes/real_state_nyasatimes/library/functions/custom_functions.php on line 401, referer: http://realestate.nyasatimes.com/ [Wed Sep 28 03:29:11 2011] [error] [client 127.0.0.1] PHP Warning: Invalid argument supplied for foreach() in /var/www/*****************/wp-content/themes/real_state_nyasatimes/library/functions/custom_functions.php on line 408, referer: http://realestate.nyasatimes.com/ [Wed Sep 28 03:36:02 2011] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function DisplayVotes() in /var/www/*****************/wp-content/themes/socialbookmark/index.php on line 49, referer: http://www.nyasatimes.com/wp-admin/my-sites.php [Wed Sep 28 03:36:57 2011] [error] [client 127.0.0.1] request failed: error reading the headers [Wed Sep 28 03:36:58 2011] [error] [client 127.0.0.1] request failed: error reading the headers [Wed Sep 28 03:36:58 2011] [error] [client 127.0.0.1] request failed: error reading the headersis it problem in wordpress multisite upgrade? i am seeing wp current user returns 0 in main site also…
See how the errors are “wp-content/themes/socialbookmark” and “wp-content/themes/real_state_nyasatimes”?
Those specifically relate to your themes. And they’re mentioning multiple themes. So I would actually switch to Twenty-Eleven.
in both seems i see same warming like “fatal error call to undefined function”
also now i switched back to twenty eleven theme, even after i login in dashboard, in meta sidebar area it still says login/register ….
so i cant think , this is theme related error.. π
now i see some thing in the apache log..
[Wed Sep 28 03:23:47 2011] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected T_STRING in /var/www/*********/wp-includes/query.php on line 187 [Wed Sep 28 03:23:50 2011] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected $end in /var/www/*********/wp-includes/query.php on line 2927, referer: http://www.nyasatimes.com/malawi/2011/09/27/poly-students-union-dissolved-over-%e2%80%98murder%e2%80%99-of-chasowa/?cp=1 [Wed Sep 28 03:23:53 2011] [error] [client 127.0.0.1] PHP Fatal error: Class 'WP_Rewrite' not found in /var/www/*********/wp-settings.php on line 236, referer: http://www.nyasatimes.com/wp-content/themes/nyasatimes_2011/style.css [Wed Sep 28 03:23:54 2011] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected $end in /var/www/*********/wp-includes/rewrite.php on line 1563 [Wed Sep 28 03:23:54 2011] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected $end in /var/www/*********/wp-includes/rewrite.php on line 1563 [Wed Sep 28 03:23:58 2011] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected T_DO in /var/www/*********/wp-includes/script-loader.php on line 307 [Wed Sep 28 03:23:58 2011] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected T_DO in /var/www/*********/wp-includes/script-loader.php on line 307 [Wed Sep 28 03:23:58 2011] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected $end in /var/www/*********/wp-includes/script-loader.php on line 477 [Wed Sep 28 03:24:04 2011] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function setup_userdata() in /var/www/*********/wp-includes/pluggable.php on line 35exactly last line is my problem.. i also see issue in other files in wp includes.. π
fyi its the lastest version of wodpress 3.2.1 … i tried to replace all wordpress files except wp config and wp content, is that can be considered as re install of wordpress??
i am also not sure this might be due to permission..
You have to test everything.
Have you turned off ALL plugins?
When you replaced all of the files other than wp-config.php and the wp-content directory, from where did you get the replacement files? Did you download a fresh copy of the WordPress ZIP file, or did you use one that was already on your computer or server? It really looks like your install files are corrupted, for some reason.
Also, you might want to check to make sure the PHP files are being uploaded as ASCII files (it’s rare, but sometimes FTP clients will try to upload them as binary files, instead).
You have to test everything.
Have you turned off ALL plugins?
i didnt tested that before.. but i tried now.. but it does not helped me..
When you replaced all of the files other than wp-config.php and the wp-content directory, from where did you get the replacement files?
i am installed the fresh set of files i downloaded.. do i need to try completely wipe off this install??
as the connection is through sftp, its binary file transfer by default… is this also troubles???
as the connection is through sftp, its binary file transfer by default
You must use ASCII mode.
The topic ‘wp_get_current_user() function returns 0 always’ is closed to new replies.