Add a Custom Role Based on Default Role (1 post)

  1. Getzel Rubashkin
    Posted 4 years ago #

    I am creating custom role and capability functionality for a plugin and I wanted to have a Business Admin role which would not have access to site management, as well as a General Admin role which would be able to access the business functionality as well as the site management.

    add_role( 'general_admin', 'General Admin');
    $admin = get_role('administrator');
    $general_admin = get_role('general_admin');
    	foreach($admin->capabilities as $cap => $bool){

    add_cap basically adds the new capability to an array stored in $general_admin->capabilities, and adds the new capability to the database. If you are not using the database to store and retrieve roles, I think you can bypass the foreach and just copy the $admin->capabilities into the $general_admin->capabilities.

    You can now add any custom capabilities you would like, or modify the capabilities as you wish.

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 4 years ago by Getzel Rubashkin
  • This topic is not resolved
  • WordPress version: 3.1.3