underscore not allowed in role slug?

admin2025-06-02  1

I created a role, 'CFI_G' in a plugin activator:

if(!role_exists('cfi_g')){ add_role('cfi_g' , 'CFI-G',
array('edit_gc_instruction')); } else {

(note the underscore in the slug)

It appeared to all go correctly and I have assigned several users to that role. However I need to loop through all roles in the site to create a select list, so I used $wp_roles:

$all_roles = $wp_roles->roles;
$editable_roles = apply_filters('editable_roles', $all_roles);

The CFI-G role does not appear in $editable_roles. However I tried adding the role of "CFI-G" using the MEMBERS plugin which created it with the slug "cfi-g". Now both the new cfi-g and the cfi_g roles appear in $editable_roles. If I delete the 'cfi-g' role, 'cfi_g' again disappears from $editable_roles.

Is an underscore NOT to be used in slugs? is there a way I can keep 'cfi_g'? Might this possibly be a bug?

thanks

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748794146a313772.html

最新回复(0)