How to ignore default roles in drupal roles I don't want to show the default roles to end user and want to ignore anonymous user and authenticated user. How can I remove these two roles from roles array. Shall I hard code the role names and rid say as in example below?

I have used this code. 

$ignore = array(1 =&gt; 'anonymous user', 2 =&gt; 'authenticated user');
$roles = user_roles();
$roles =  array_diff($roles, $ignore);


Thanks for your help.
If you call user_roles(TRUE), the function will not return the anonymous user role.

Drupal always sets the role ID for anonymous user role, and the authenticated user role to the value of the constants DRUPAL_ANONYMOUS_RID, and DRUPAL_AUTHENTICATED_RID.

The following code is executed by user_install() in Drupal 7, and similar code is executed by system_install() in Drupal 6.

// Built-in roles.
  $rid_anonymous = db_insert('role')
    -&gt;fields(array('name' =&gt; 'anonymous user', 'weight' =&gt; 0))
    -&gt;execute();
  $rid_authenticated = db_insert('role')
    -&gt;fields(array('name' =&gt; 'authenticated user', 'weight' =&gt; 1))
    -&gt;execute();

  // Sanity check to ensure the anonymous and authenticated role IDs are the
  // same as the drupal defined constants. In certain situations, this will
  // not be true.
  if ($rid_anonymous != DRUPAL_ANONYMOUS_RID) {
    db_update('role')
      -&gt;fields(array('rid' =&gt; DRUPAL_ANONYMOUS_RID))
      -&gt;condition('rid', $rid_anonymous)
      -&gt;execute();
  }
  if ($rid_authenticated != DRUPAL_AUTHENTICATED_RID) {
    db_update('role')
      -&gt;fields(array('rid' =&gt; DRUPAL_AUTHENTICATED_RID))
      -&gt;condition('rid', $rid_authenticated)
      -&gt;execute();
  }


The following code works also in Drupal 5; the $roles array will not contain information about the anonymous user, and the authenticated user roles.

$roles = user_roles(TRUE);
unset($roles[DRUPAL_AUTHENTICATED_RID]);