MacBook avec code sur un bureau

WordPress – Know if the user is an administrator

To find out if the current user is an administrator in WordPress, i.e. if they have the right to set up options:

if ( ! current_user_can( 'manage_options' ) ) {
    echo "You are not admin";
} else {
    echo "You are an admin";
}