Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How to create new role with same capabilities of existing role. Eg: I would like to create a new role with same capabilities of administrator or editor and so on..

share|improve this question
What have you tried? What worked? What didn't? Have you tried Members Plugin? Or Capability Manager Plugin? Do they do the things you want? – soulseekah Oct 19 '11 at 5:42

2 Answers

up vote 6 down vote accepted

Try this... This should work.

<?php
add_action('init', 'cloneRole');

function cloneRole()
{
    global $wp_roles;
    if ( ! isset( $wp_roles ) )
        $wp_roles = new WP_Roles();

    $adm = $wp_roles->get_role('administrator');
    //Adding a 'new_role' with all admin caps
    $wp_roles->add_role('new_role', 'My Custom Role', $adm->capabilities);
}
?>

Check it.

share|improve this answer
awesome script... thank you very much :-) – notme Oct 19 '11 at 6:16
You're welcome :) – Rutwick Gangurde Oct 19 '11 at 6:35
Great snippet! Very useful. – Jake Dec 13 '12 at 20:40
Glad I could help Jake! – Rutwick Gangurde Dec 14 '12 at 19:30

You can use User Role Editor if you want to do everything visually :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.