Remove AIOSEO Details for all users except one
-
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-16434394This 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)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Remove AIOSEO Details for all users except one’ is closed to new replies.