Redirecting and removing user role after user account submit I like to redirect my users after they submit their user/edit page.
On their user/edit submit i like to remove a certain role from them as well.
The redirect hasn't been a problem however removing the role is.

In a custom module i have the following code:

  function regform_user_profile_form_submit($form, &amp;$form_state) {
  global $user; 
 drupal_goto('user/' . $user-&gt;uid);


I am quit a beginner with php and couldn't find any could that fitted in this function properly.
Using rules is not an option as it conflicts with the Oauth module.

Help appreciated,
thanks.
I would try implementing hook_user_presave().

function custom_module_user_presave($edit, $account, $category) {
  $role_position = array_search('undesired_role', $account-&gt;roles);
  // Use !== or === here since $role_position may be zero or FALSE
  if ($role_position !== FALSE) {
    unset($account-&gt;roles[$role_position]);
  }
}