Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Garconis/d7125787022eb325426706ac2d19cc5d to your computer and use it in GitHub Desktop.
Save Garconis/d7125787022eb325426706ac2d19cc5d to your computer and use it in GitHub Desktop.
WordPress | Hide the AIOSEO Details column for users without a certain email address
<?php
// enable if AIOSEO is active
if ( function_exists( 'aioseo' ) ) {
// fires after WordPress has finished loading but before any headers are sent.
add_action( 'init', function() {
// get current User
$user = wp_get_current_user();
// get their email address
$email = $user->user_email;
// check the email's domain
$domain = 'example.com';
// check if email address matches domain list
$banned = strpos($email, $domain) === false;
// if current user's email address doesn't match domain list
if( $user && $banned ) {
// remove the AIOSEO Details column for users without a particular email address domain
remove_action( 'current_screen', [ aioseo()->admin, 'addPostColumns' ], 1 );
}
} );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment