Solved

wordpress add_cap not working

Posted on 2015-02-15
1
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

In Part I (http://www.experts-exchange.com/Web_Development/Blogs/WordPress/A_8410-Getting-Started-In-WordPress-Part-I.html), I introduced you to the powerful WordPress backend, the WordPress administrative Dashboard.  In Part II, I will introduce yo…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

695 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