May 2017
Beginner to intermediate
536 pages
14h 25m
English
Capabilities are always associated with user roles and hence we cannot create new capabilities without providing a user role. Let's look at the following code for associating custom capabilities with our member user roles created earlier in the Creating application user roles section:
public function add_application_user_capabilities(){ $role = get_role( 'wpwaf_premium_member' ); $role->add_cap( 'follow_forum_activities' ); $role = get_role( 'wpwaf_free_member' ); $role->add_cap( 'follow_forum_activities' ); }
First, we need to retrieve the user role as an object using the get_role function. Then, we can associate new or existing capability using the add_cap function. We need to continue this process ...
Read now
Unlock full access