PHP Developer

Showing posts with label add_role(). Show all posts
Showing posts with label add_role(). Show all posts

Monday, 28 March 2016

Create New User Role With Capability in Wordpress

Create New User Role With Capability in Wordpress


Add below code in function.php, then new role "Client" is registered with capabilities .

<?php
$result = add_role( 'client', __(

'Client' ),

array(

'read' => true, // true allows this capability
'edit_posts' => true, // Allows user to edit their own posts
'edit_pages' => true, // Allows user to edit pages
'edit_others_posts' => true, // Allows user to edit others posts not just their own
'create_posts' => true, // Allows user to create new posts
'manage_categories' => true, // Allows user to manage post categories
'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
'edit_themes' => false, // false denies this capability. User can’t edit your theme
'install_plugins' => false, // User cant add new plugins
'update_plugin' => false, // User can’t update any plugins
'update_core' => false // user cant perform core updates

)

);

?>

Sunday, 19 October 2014

How To Create Custom User Role or User type in Wordpress

How To Create Custom User Role in Wordpress


<?php add_role( $role, $display_name, $capabilities ); ?>

Example :
add_role('basic_contributor', 'Basic Contributor', array(
               'read' => true, // True allows that capability
               'edit_posts' => true,
               'delete_posts' => false, // Use false to explicitly deny
));