Solved

wordpress add_cap not working

Posted on 2015-02-15
1
128 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Who says nothing in life is free? WordPress.com is a freebie. WordPress.org's downloadable publishing platform is free. Heck, even WordPressMU is free. WordPress is an open source project, which means it can be used on any personal or commerc…
Like there are many different versions of Wordpress, there are also a handful of related side projects WordPress users should be familiar with.   All of these projects are open source and GPL licensed, which means there are few restrictions to us…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now