Last active
October 12, 2018 03:55
-
-
Save miclow/837a5a49bdf2bb2461312bd7f0552c1a to your computer and use it in GitHub Desktop.
PHP set cookie (user_is_admin) when visitor access the admin of Wordpress
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
function my_exclude_admin_cookie() { | |
$expire_time = time() + 60 * 60 * 24 * 180; | |
setcookie( 'user_is_admin', 'true', $expire_time, '/' ); | |
} | |
if( is_admin() ) { | |
add_action('init', 'my_exclude_admin_cookie'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment