mailusers_get_roles() function to use the core get_editable_roles( )
-
Is there a chance that you can change the mailusers_get_roles() function to use the core get_editable_roles( ) function?
I’d like to use email-users but I don’t want to open up all the site roles/groups to users who just have the email_user_groups capability if they shouldn’t be able to see a particular role. The standard WordPress get_editable_roles( ) function allows for roles to be excluded from users and it would be great if email-users could take advantage of this flexibility.
The current function mailusers_get_roles looks like this ..
function mailusers_get_roles( $exclude_id='', $meta_filter = '') { $roles = array(); $wp_roles = new WP_Roles(); foreach ($wp_roles->get_names() as $key => $value) { $users_in_role = mailusers_get_recipients_from_roles(array($key), $exclude_id, $meta_filter); if (!empty($users_in_role)) { $roles[$key] = $value; } } return $roles; }
I suggest this..
function mailusers_get_roles( $exclude_id='', $meta_filter = '') { $roles = array(); $wp_roles = get_editable_roles( ); $wp_roles['roles'] = $wp_roles; foreach ($wp_roles as $key => $values) { $users_in_role = mailusers_get_recipients_from_roles(array($key), $exclude_id, $meta_filter); if (!empty($users_in_role)) { $roles[$key] = $values['name']; } } return $roles; }
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘mailusers_get_roles() function to use the core get_editable_roles( )’ is closed to new replies.