Answers for "wp create user role"

PHP
2

wordpress make custom role

/* Create Staff Member User Role */
add_role(
    'staff_member', //  System name of the role.
    __( 'Staff Member'  ), // Display name of the role.
    array(
        'read'  => true,
        'delete_posts'  => true,
        'delete_published_posts' => true,
        'edit_posts'   => true,
        'publish_posts' => true,
        'upload_files'  => true,
        'edit_pages'  => true,
        'edit_published_pages'  =>  true,
        'publish_pages'  => true,
        'delete_published_pages' => false, // This user will NOT be able to  delete published pages.
    )
);
Posted by: Guest on September-29-2020
1

wp add role capabilities

######## Custom Code ############

// get the the role object
$role_object = get_role( $role_name );

// add $cap capability to this role object
$role_object->add_cap( $capability_name );

// remove $cap capability from this role object
$role_object->remove_cap( $capability_name );

reference:
https://wordpress.stackexchange.com/questions/13413/how-to-add-a-capability-to-a-user-role

######## From Plugins ############
https://wordpress.org/plugins/members/
https://wordpress.org/plugins/user-role-editor/#description
https://wordpress.org/support/article/roles-and-capabilities/#manage_network_plugins
Posted by: Guest on June-07-2021

Browse Popular Code Answers by Language