How to create a clone role in wordpress
Question
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..
in progress
0
capabilities, user-roles
11 years
2011-10-19T00:33:43-05:00
2011-10-19T00:33:43-05:00 0 Answer
56 views
0
Answer ( 1 )
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.