Using the Default Role Filter

The Multiple Roles Interface function to update user roles on the user-edit.php page has a filter hook, swt_modify_multi_roles_default, that allows you to assign the default role of your choice when a user has no roles. This feature works only when the constant MULTI_ROLES_EDIT_DEFAULT is defined as true.


Whatever function you pass to this hook, it must always pass in the array $user_new_roles as an argument and return $user_new_roles as an array of the same form.

Example: Setting the Default to Contributor

function swt_default_to_contributer($user_new_roles)
  $user_new_roles = array('contributor');
  return $user_new_roles;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s