how can we disable profile.php for subscriber in wordpress

I would like to disable the profile.php(complete dashboard) for subscribers only. they only veiw the main website, they can’t view the dashboard panel. We have also made some roles for subscriber using cpca plugin, due to this visitor can view some pages, which only can possible through login in website.

Please suggest me any plugins, or tips to complete this task,

Read More

Thanks

Alen

Related posts

Leave a Reply

2 comments

  1. I just had to figure this out… unfortunately, there aren’t many great options in WordPress for disabling the profile page, so I had to use wp_die() on the page load action.

    function disable_user_profile() {
    
        if ( is_admin() ) {
    
            $user = wp_get_current_user();
    
            if ( 2 == $user->ID )
                wp_die( 'You are not allowed to edit the user profile on this demo.' );
    
        }
    
    }
    add_action( 'load-profile.php', 'disable_user_profile' );
    

    In my example, I want to prevent a single user from editing their profile (it’s for a demo site, blocking the demo admin user). But you could easily do a role or permission or anything else you want.