?
Solved

wordpress add_cap not working

Posted on 2015-02-15
1
Medium Priority
?
224 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 2000 total points
ID: 40611065
On line 10, try changing your variable name to $role_owner.
0

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

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…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

800 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