Wordpress - How to create a clone role in wordpress

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.


You could always use the User Role Editor plugin;

  1. Install the plugin
  2. Go to Users > User Role Editor
  3. Click "Add Role" to the right
  4. Choose the role you wish to duplicate from the "Make copy of" dropdown in the dialogue box
  5. Click "Add Role" in the dialogue box