• Resolved Sharon

    (@shpemu)


    Hi there. I’m unable to use this plugin for all users. Only administrators can like or unlike items. Please advise.

    Thank you,
    Sharon

Viewing 1 replies (of 1 total)
  • Thread Starter Sharon

    (@shpemu)

    Hey all. Found my answer. I had a security plugin that was keeping anyone who wasn’t an admin out of the admin dashboard area.

    My original code for this looked like this:

    function restrict_admin_access() {
    	if(!current_user_can('administrator')) {
    		wp_redirect( get_bloginfo('url') );
    		exit;
    	}
    }
    add_action( 'admin_init', 'restrict_admin_access', 1 );

    My new code looks like this:

    function restrict_admin_access() {
    	if(!current_user_can('administrator') && !wp_doing_ajax()) {
    		wp_redirect( get_bloginfo('url') );
    		exit;
    	}
    }
    add_action( 'admin_init', 'restrict_admin_access', 1 );

    The “like” plugin works wonderfully now.

Viewing 1 replies (of 1 total)

The topic ‘Plugin only works for administrators’ is closed to new replies.