• Resolved ellmann creative

    (@ellmanncreative)


    What you did is basically this:

    
    if (!function_exists('wp_get_current_user')) {
    	require_once(ABSPATH . "wp-includes/pluggable.php");
    }
    

    – which works, but if there’s anything that tries to load it later, you’ll get a fatal on function redefinition.

    A better way to fix the issue is to change this:

    if (is_admin() or is_super_admin()) {
    	// add_action('admin_enqueue_scripts', 'restore_classic_load_upsell');
    	add_action('wp_ajax_restore_install_plugin2', 'restore_install_plugin2');
    	add_action('wp_ajax_nopriv_restore_install_plugin2', 'restore_install_plugin2');
     }

    to this:

    add_action('init', function(){if (is_admin() or is_super_admin()) {
    	// add_action('admin_enqueue_scripts', 'restore_classic_load_upsell');
    	add_action('wp_ajax_restore_install_plugin2', 'restore_install_plugin2');
    	add_action('wp_ajax_nopriv_restore_install_plugin2', 'restore_install_plugin2');
     }});
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ellmann creative

    (@ellmanncreative)

    Also, is_admin checks if the page is the administrative interface (i.e. /wp-admin). is_super_admin checks if the USER has super-admin capabilities. Why are you mixing the two?

    This mix of “or” will make this ajax fire on the website’s front-end, IF the user is a super-administator…

    You should fix that by changing is_admin() or is_super_admin() (which isn’t what you want) to is_admin() and current_user_can("install_plugins") or something similar (current_user_can() always returns true for super-admin).

    Plugin Author Bill Minozzi

    (@sminozzi)

    Hi Ellmann,

    Thanks for your suggestions!
    I will study that and run tests.

    Cheers,
    Bill

    Plugin Author Bill Minozzi

    (@sminozzi)

    Hi Ellmann,

    I uploaded the version 2.1 with your suggestion of
    add_action(‘init’…
    and that fixed the issue for one user.
    Thanks again.

    Cheers,
    Bill

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘v2.0 fixes “wp_get_current_user” in the worst way possible’ is closed to new replies.