Link to home
Start Free TrialLog in
Avatar of Sean Clarke
Sean ClarkeFlag for United Kingdom of Great Britain and Northern Ireland

asked on

wordpress add_cap not working

I'm trying to clone a user role in WordPress to give an editor role slightly more ability.

The following line causes the white screen of death:
$role_owner->add_cap('edit_theme_options');

Open in new window


Can anyone help to add this simple additional capability?
Full function listed below for reference.

add_action('init', 'createUserRole');

function createUserRole()
{
 global $wp_roles;

 if (!isset($wp_roles))
  $wp_roles = new WP_Roles();

 $role_editor = $wp_roles->get_role('editor');
 $role_owner  = $wp_roles->add_role('owner', 'Site Owner', $role_editor->capabilities);
 $role_owner->add_cap('edit_theme_options');
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Heather Ritchey
Heather Ritchey
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial