Last active
February 8, 2021 17:13
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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