i want author role can't access wp-admin but still enable the capabilities so they can delete the posts from front end page ?


Use this code in your functions.php file or in a plugin-

function wpse_253580_prevent_author_access(){
    if( current_user_can( 'author' ) && is_admin() )  {
        // do something here. maybe redirect to homepage
        wp_safe_redirect( get_bloginfo( 'url' ) );
add_action( 'admin_init', 'wpse_253580_prevent_author_access' );

This will check if current user is an author and he is trying to access wp-admin area. If true, then redirect him to homepage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.