• Resolved Jon

    (@freshyjon)


    Given this solution, how would you update the code snippet to remove the AIOSEO Details column for all users except a given email address.

    https://www.ads-software.com/support/topic/remove-aioseo-details-via-remove_action/#post-16434394

    This is the code, we had that was previously working, but no longer works as of a week or so ago. It just shows the AIOSEO Details column with the animation of it loading: https://freshy.media/captures/GTFAj3FHzy.gif

    /* -- All in One SEO Pack -- */
    
    // disable the AIOSEO Details column for users that don't have a certain email address
    // https://www.ads-software.com/support/topic/remove-aioseo-details-via-remove_action/#post-16434394
    add_action( 'current_screen', 'remove_aioseo_column', 0 );
    function remove_aioseo_column() {
    	
    	// get current User
    	$user = wp_get_current_user(); 
    	// get their email address
    	$email = $user->user_email;
    	// check the email's domain
    	$domain = 'example.org';
    	// check if email address matches domain list
    	$banned = strpos($email, $domain) === false;
    
    	// get all the actions and filters
    	global $wp_filter;
    
    	// if it's current screen isn't set, then get out of the function
    	if ( empty( $wp_filter['current_screen'][1] ) ) {
    		return;
    	}
    	// go through each current screen details
    	foreach ( $wp_filter['current_screen'][1] as $actionName => $params ) {
    		if (
    			empty( $params['function'][0] ) ||
    			! is_object( $params['function'][0] ) ||
    			stripos( get_class( $params['function'][0] ), 'aioseo' ) === false
    		) {
    			continue;
    		}
    		// if user is banned (without a particular email address domain), then hide the AIOSEO Details screen option (and thus the AIOSEO column)
    		if ( $user && $banned ) {
    			remove_action( 'current_screen', $params['function'], 1 );
    		}
    	}
    
    }

    When that if statement wraps the remove_action, it causes this error in the Console:

    links.6fea55de.js:5 Uncaught TypeError: Cannot read properties of undefined (reading '_s')
        at o (links.6fea55de.js:5:3384)
        at Object.Wl [as restUrl] (links.6fea55de.js:10:84363)
        at posts-table.2c706223.js?ver=4.5.6:1:18775
    o @ links.6fea55de.js:5
    Wl @ links.6fea55de.js:10
    (anonymous) @ posts-table.2c706223.js?ver=4.5.6:1

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author arnaudbroes

    (@arnaudbroes)

    Hey Jon, I’ve asked one of our developers to look into this for you. I’ll get back to you with an update soon.

    Jon Fuller

    (@garconis)

    FYI, this is actually happening on website without any sort of custom AIOSEO function/filter/action.

    Plugin Author arnaudbroes

    (@arnaudbroes)

    In that case it might be worth trying out our new update that is going out tomorrow. We fixed an issue that is related to the details column loading endlessly for specific users. Can you perhaps try it out when it goes out and let us know if it does (not) fix the issue for you?

    Plugin Support Prabhat

    (@prabhatrai)

    Hey @garconis,

    Could you please go to your WordPress Dashboard > Plugins > Installed Plugins, update All in One SEO to our latest version v4.5.7.2 and see if that fixes the issue?

    Please let me know if the issue persists so I can investigate further.

    I’m really looking forward to helping you.

    Thanks!

    Jon Fuller

    (@garconis)

    Yes, that seems to have fixed it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Remove AIOSEO Details for all users except one’ is closed to new replies.