WordPress.org

Ready to get started?Download WordPress

Forums

BulletProof Security
[resolved] Call to undefined function wp_get_current_user() (8 posts)

  1. Eddie
    Member
    Posted 1 year ago #

    After updating to the latest BPS, on a multisite WP installation v. 3.5.1, admin pages immediately became unavailable, due to the following error:

    PHP Fatal error: Call to undefined function wp_get_current_user() in /home/apache/wordpress/wp-includes/capabilities.php on line 1451

    According to:
    https://wordpress.org/support/topic/plugin-post-from-site-fatal-error-undefined-function

    when this happens it is because wp-includes/pluggable.php contains this function, but this file is not getting loaded until after the plugins are loaded.

    I was able to fix the problem by adding:
    require_once(ABSPATH . 'wp-includes/pluggable.php');

    to /wp-content/plugins/bulletproof-security/bulletproof-security.php

    as soon as I added that line admin pages became accessible again and the error is no longer triggered.

    http://wordpress.org/extend/plugins/bulletproof-security/

  2. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Wierd. BPS does not use the wp_get_current_user() function. BPS does use the WordPress current_user_can() function to check user capabilities.

    Try commenting out the line you added below with 2 forward slashes and let me know if the error occurs again. It may have just been a coincidence or maybe there is some other factor that is not obvious going on.
    // require_once(ABSPATH . 'wp-includes/pluggable.php');

  3. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Did you Network Activate BPS on your Network/Multisite installation? BPS should not be Network Activated and should only be activated on the Primary site for Network/Multisite.

  4. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Oops yeah wp_get_current_user() is in capabilities and not BPS. Spaced out for a sec. LOL. Apparently this is some odd random occurrence that happens only on Mulitsite and I do not see that anyone has ever figured out what actually causes it. I will add this as it would not hurt anything, but I will need to research it fully before adding it. Thanks.

  5. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    This has been researched and tested and everything works perfectly. Thank you for pointing this out. Very much appreciated.

  6. Eddie
    Member
    Posted 1 year ago #

    It was my pleasure, and many thanks for being so responsive, and for your work on this excellent plugin :-)

    Look forward to the fix appearing soon, but if it doesn't, no big deal, I have my ugly kludge patch. Here it is in case it helps any multisite people until the real fix is merged:

    --- a/wp-content/plugins/bulletproof-security/bulletproof-security.php  2013-04-17 23:11:09.640004664 +0100
    +++ b/wp-content/plugins/bulletproof-security/bulletproof-security.php  2013-04-17 23:10:30.610004665 +0100
    @@ -46,6 +46,7 @@
    
     // If in WP Admin Dashboard
     if ( is_admin() ) {
    +    require_once(ABSPATH . 'wp-includes/pluggable.php');
         require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/includes/admin.php' );
            register_activation_hook(__FILE__, 'bulletproof_security_install');
            register_deactivation_hook(__FILE__, 'bulletproof_security_deactivation');
  7. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    adding just...

    require_once(ABSPATH . 'wp-includes/pluggable.php');

    ...causes some problems for other plugins so this code will be changed to include this additional conditional check below...

    if ( is_admin() ) {
        require_once( WP_PLUGIN_DIR . '/bulletproof-security/admin/includes/admin.php' );
    	if ( wp_script_is( 'bps-js', $list = 'queue' ) ) {
    		require_once(ABSPATH . 'wp-includes/pluggable.php');
    	}

    Please test this code on your site and let me know if it works. Thanks.

  8. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Wow dumb one. Went down the rabbit hole looking in the wrong place. This is the correct solution to the problem.
    http://wordpress.org/support/topic/36-beta-issue?replies=3

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.