Fatal Error Call To Undefined Function Wp_get_current_user In Plugin
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack wp get current user role Overflow the company Business Learn more about hiring developers or posting ads with us
Wp Get Current User Name
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community wp_get_current_user() in wordpress of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up wordpress plugin -> Call to undefined function wp_get_current_user() up vote 12 down vote favorite 2 I'm capabilities.php wordpress trying to get the current user info in my plugin using the func wp_get_current_user(). But am getting Call to undefined function wp_get_current_user() Apparently this is happening because the file /wp-includes/pluggable which contains the function doesn't get loaded until after the plugins are loaded. Anybody any ideas on how to get the user details in my plugin? php wordpress-plugin wordpress share|improve this question edited Apr 26 at 23:32 madhead 7,97054787 asked May 25
Wordpress Call To Undefined Function
'11 at 16:14 Daithí 2,41321526 add a comment| 5 Answers 5 active oldest votes up vote 16 down vote accepted Apparently this is happening because the file /wp-includes/pluggable which contains the function doesn't get loaded until after the plugins are loaded. Indeed it is. So wrap whichever thing you're doing in a function, and hook it onto the plugins_loaded or init hook. (see the wp-settings.php file) Example: add_action('init','do_stuff'); function do_stuff(){ $current_user = wp_get_current_user(); // ... } share|improve this answer edited Sep 23 '15 at 7:29 answered May 25 '11 at 16:18 Denis de Bernardy 46.5k562106 3 worked like a charm. I was working of a class that loaded the user details on construct. So here's the code for anyone else. I now have: `add_action('plugins_loaded','construct_my_class'); function construct_my_class(){ $controller = new myClass(); } –Daithí May 25 '11 at 19:28 where to add the code? @Coombesy? –Prakash Mar 18 '14 at 19:11 @Prakash depends on your plugin architecture. For most wordpress development I would imagine it would go in the plugins index.php file –Daithí Mar 18 '14 at 21:21 add a comment| up vote 10 down vote You can use this, this should fix your problem :) share|improve this answer answered May
7 years, 8 months ago I installed WPMU, which seems to be working fine. After I installed the buddypress plugin, I am getting the following error whenever I try to view my site: Call to undefined function wp_get_current_user() in /html/wp-includes/capabilities.php line 920. But wp_get_current_user not working if I remove the buddypress plugin, the WPMU works fine. (Note that the relevant fatal error call to undefined function wordpress permissions are already set to 755.) I've been hearing that this is caused by a widget error in one of the buddypress
Call To Undefined Function Wp_delete_user
plugins, but am not sure how to fix it. Any advice would be appreciated. Viewing 10 replies - 1 through 10 (of 10 total) Burt AdsitParticipant @burtadsit 7 years, 8 months ago Haven't run across http://stackoverflow.com/questions/6127559/wordpress-plugin-call-to-undefined-function-wp-get-current-user this as an issue with bp before. Trent AdamsParticipant @trent 7 years, 8 months ago I don't think it is exactly a strictly BP issue, but I have no idea other than this google search. Trent jfcarterParticipant @jfcarter 7 years, 8 months ago I found this post and it helped (https://mu.wordpress.org/forums/topic.php?id=7393) In file wp-includes/capabilities.php add on line 2: require_once(‘pluggable.php'); Worked PERFECTLY! nicolagrecoParticipant @nicolagreco 7 years, 8 months ago you should update your https://buddypress.org/support/topic/fatal-error-call-to-undefined-function-wp_get_current_user/ mu! jfcarterParticipant @jfcarter 7 years, 8 months ago Why? It's working now! nicolagrecoParticipant @nicolagreco 7 years, 8 months ago because i think you're using svn, you should upgrade to the final jfcarterParticipant @jfcarter 7 years, 8 months ago @nicolagreco, Thank you for your post. I thought I downloaded the buddypress combo, which is the final version. I didn't even go to the SVN site. Is there someplace I can double check to make sure I have the final version? Thanks, Jessica DevrimParticipant @devrim 7 years, 8 months ago Jessica, it has nothing to do with update, svn, final or whatsoever.. only the fix below works. like you posted. In file wp-includes/capabilities.php add on line 2: require_once(‘pluggable.php'); thanks, it helped us too. DevrimParticipant @devrim 7 years, 8 months ago and to whom it may concern; these kind of errors are discouraging. If we had a decent buddypress alternative we would have switched already. $bp related errors* and errors that belong to the core, very demotivating as they are making our whole system unstable. We spend hours first on the system try to find what's wrong, and hours on internet try to find if anyone else has a fix. * https://buddypress.org/forums/topic.php?id=1125&replies=14#post-6258 Andy PeatlingKeymaster @apeatling 7 years, 8 months ago Welcome to pre-release software devrim. Make sur
tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us http://wordpress.stackexchange.com/questions/92517/fatal-error-call-to-undefined-function-wp-get-current-user Learn more about Stack Overflow the company Business Learn more about hiring developers or http://victorfont.com/fix-capabilities-php-fatal-error/ posting ads with us WordPress Development Questions Tags Users Badges Unanswered Ask Question _ WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers call to are voted up and rise to the top Fatal error: Call to undefined function wp_get_current_user() up vote 2 down vote favorite 4 I have some strange error or may be I do not have the skills to tackle this issue. I am building a plugin for Multisite. When is use is_admin(), my plugin works fine but when I use is_super_admin it shows me this error Fatal error: Call call to undefined to undefined function wp_get_current_user(). I did my search but could not be able to find any solution. My Code is this if(!is_super_admin()){ add_action('widgets_init','my_unregister_widdget'); function my_unregister_widgets() { unregister_widget( 'WP_Widget_Pages' ); unregister_widget( 'WP_Widget_Calendar' ); } } I saw this question but it's not helping me. plugins multisite share|improve this question edited Mar 27 '13 at 11:20 brasofilo 17.1k435151 asked Mar 27 '13 at 6:22 Husnain 1313 Just a note: is_admin() checks if you are in back or front end, it has nothing to do with the user being "admin". Opposed to is_super_admin(), which indeed checks for the user role. Also, please don't Multi-post the same Question in different Stack sites. –brasofilo Mar 27 '13 at 12:11 add a comment| 1 Answer 1 active oldest votes up vote 5 down vote accepted wp_get_current_user() is a pluggable function and not yet available when your plugin is included. You have to wait for the action plugins_loaded: Example: add_action( 'plugins_loaded', 'wpse_92517_init' ); function wpse_92517_init() { if(!is_super_admin()) add_action('widgets_init','my_unregister_widget'); } function my_unregister_widgets() { unregister_widget( 'WP_Widget_Pages' ); unregister_widget( 'WP_Widget_Calendar' ); } Or move the check into the widget function: add_action( 'widgets_init', 'my_unregister_widget' ); function my_unregister_widgets() { if ( is_super_admin() ) return; // not super admin unregister_widget( 'WP_Wid
WordPress?WordPress.com vs. WordPress.orgInstalling WordPressFree PluginsPortfolioWebsite CareResourcesBooks We've WrittenFree WordPress TrainingTraining RegistrationLooking for a Speaker?Publishing ServicesContact UsOpen a Support TicketAbout Victor M. Font Jr. Search this website You are here: Home / Code Snippet / Fix WordPress Capabilities.php Fatal ErrorFix WordPress Capabilities.php Fatal ErrorBy Victor M. Font Jr.March 7, 20147 CommentsPublic Domain Image from Pixabay.ComSince the upgrade to WordPress 3.6, my multi-site installation has been plagued with the following error:
[28-Aug-2013 13:02:59 UTC] PHP Fatal error: Call to undefined function wp_get_current_user() in /public_html/wp-includes/capabilities.php on line 1281First, the error occurred when I deactivated the NextGen Gallery plugin on http://www.fontlife.com/. Deactivating the plugin caused the error to rear its ugly head which causes the site to fail to load.Next, it happened when I disabled open registration using the S2Member plugin on this site. Deactivating open registration caused the S2Member general options screen to lose it's formatting and appear as one giant text file. When I attempted to visit the site, the site failed to load displaying the above error message instead.After researching the error, I found several references to a fix that most writers were unsure that it is the proper fix or not. The fix requires modifying the wp-includes/capabilities.php file. This is a WordPress core file. Modifying any WordPress core file is generally a big no-no, but in this case, adding a single line to capabilities.php fixes a multitude of sins. The problem with modifying a WordPress core file is that once you do, you'll have to keep doing it every time there's an update issued for WordPress.Author's note: Once you modify a WordPress core file, you'll have to keep applying the fix every time there's an update issued for WordPress.There are references to this problem that extend back to the release of WordPress 3.0.1. At least one WordPress Developer, Andrew Nacin, mentioned in a 2011 post that he thought the issue began with https://core.trac.wordpress.org/changeset/15452, released on 07/21/10. In that post, Nacin says:pluggable.php doesn't