0

WordPress: How Remove Subcriber’s Permission to View WP Profile

posted on July 18, 2012 09:17 AM by Jhoy Imperial

Sometimes your theme requires that the Subscribers group shouldn’t be allowed to view their profile page or modify their account information.

In order to achieve this, you must remove the user level’s capability to view their account page.

Add the following script to your functions.php to remove the permission

{code type=”}
add_action( ‘admin_init’, ‘theme_admin_init’ );
function theme_admin_init(){
global $wp_roles;
$wp_roles->remove_cap( ‘subscriber’, ‘read’ );
}
{/code}

On the other hand, if you need to add the permission back, just use the code below.

{code type=”}
add_action( ‘admin_init’, ‘theme_admin_init’ );
function theme_admin_init(){
$role = get_role( ‘subscriber’ );
$role->add_cap( ‘read’ );
}
{/code}

WordPress Readings and Resources

posted on July 18, 2012 09:17 AM by Jhoy Imperial
under How To, Tutorials, Wordpress
tagged


Recent Tweets

 

Email us at support@codingcereal.com

Copyright 2009 - 2013 © www.codingcereal.com