Solved

wordpress add_cap not working

Posted on 2015-02-15
1
153 Views
Last Modified: 2015-03-30
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

0
Comment
Question by:Sean Clarke
1 Comment
 
LVL 14

Accepted Solution

by:
Dzynit earned 500 total points
ID: 40611065
On line 10, try changing your variable name to $role_owner.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to install BuddyPress on your self-hosted WordPress site It’s been called everything from “social networking in a box” to “Facebook without the terms of service,” but until Feb. 16, BuddyPress was a relatively unknown outside the WordPress MU…
I want to start by talking about the use of plug-ins for WordPress. I started a web-site for a company I was working for a few years ago; I had extremely basic knowledge of HTML. I am a Graphic Designer by trade so I invited the opportunity as a cha…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question