The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Disable WordPress Dashboard Access for Subscribers

Shared by Amit Dholiya · October 17, 2026 · @admin_init

14 views
Back to Snippets

Steps

  1. Add the PHP code to your child theme’s functions.php file or the Code Snippets plugin.

  2. Save and activate the snippet.

  3. Log in using a Subscriber account and try to open the WordPress dashboard.

Hook Used

– admin_init — Runs during WordPress admin initialization and redirects matching users.

Type: WordPress Access Customization

Output: Users with the Subscriber role are redirected to the website homepage when accessing the admin area.

Note: This is a dashboard redirect, not a complete security system. It targets users with the subscriber capability check; if you want to target the exact Subscriber role, check the user’s role explicitly. Admins and other roles are not affected by this snippet.

function custom_redirect_subscriber_dashboard() {
    if (
        is_admin()
        && ! wp_doing_ajax()
        && current_user_can( 'subscriber' )
    ) {
        wp_safe_redirect( home_url( '/' ) );
        exit;
    }
}
add_action( 'admin_init', 'custom_redirect_subscriber_dashboard' );

Tested on

WordPress 6.8

Reported by the author on October 17, 2026. WPFolks has not verified this.

Not tested against WordPress 7.1.4. It may still work.

Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments

Proudly supported by