Assingning a capability to a user role (code check)


I wrote this piece of code to add manage_options capability to my shop_managers, and it does work. I wanted to ask before i move this code to my live site, if the function is called in the right place.
I thank you in advance!

add_action('init', 'activate_cap_shopmanagers');
function activate_cap_shopmanagers() {
        // get the shop manager role's object from WP_Role class
        $shopmanager = get_role( 'shop_manager' );
        // add the capability
        $shopmanager->add_cap( 'manage_options' );

John Aps 6 months 2022-02-12T04:53:24-05:00 0 Answers 0 views 0

Leave an answer