Reset password via Services by email, and not by uid I'm trying to POST an email address to the password_reset Services endpoint so that it generates and sends a password reset email for a user. When I post the uid to the endpoint, it does this successfully. That said, I want to post the user's email to the endpoint (e.g. they type in their email to retrieve their password recovery email). How can I change the below in order to allow this? I tried changing user_load($uid) to user_load_by_mail($uid), but this didn't work.

Endpoint format: 


  mydomain.com/myendpoint/user/emailhere@go.com/password_reset_email


user_resource.inc 

  $definition = array(
  'user' =&gt; array(
  'operations' =&gt; array(
  'actions' =&gt; array( 
    'help' =&gt; 'Send forgot password email',
    'callback' =&gt; '_user_resource_password_reset_email',
    'access callback' =&gt; 'services_access_menu',
    'args' =&gt; array(
      array(
        'name' =&gt; 'email',
        'optional' =&gt; FALSE,
          'source' =&gt; array('data' =&gt; 'email'),
        'type' =&gt; 'string',
        'description' =&gt; 'The email address of the user whose password should be reset.',
      ),
      ),
    ),
    ),
    ),
  ),

       function _user_resource_password_reset_email($data) {
  global $language;


  $mail = _services_arg_value($data, 'data');
  $account = user_load_by_mail($mail);

  if (empty($account)) {
    return services_error(t('There is no user with email @email.', array('@email' =&gt; $mail)), 404);
  }

  // Mail one time login URL and instructions using current language.
  $mail = _user_mail_notify('password_reset_email', $account, $language);
  if (!empty($mail)) {
    watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' =&gt; $account-&gt;name, '%email' =&gt; $account-&gt;mail));
  }
  else {
    watchdog('user', 'There was an error re-sending password reset instructions mailed to %name at %email', array('%name' =&gt; $account-&gt;name, '%email' =&gt; $account-&gt;mail));
}

  $result = "success";
  return $result;
}


Obj-C

ViewController.m

- (IBAction)sendButton:(id)sender {

[DIOSUser userSendPasswordRecoveryEmailWithEmailAddress:self.forgotField.text
                                                            success:^(AFHTTPRequestOperation *operation, id responseObject) {

                                                                NSLog(@"Password being sent!");

                                                                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Retrieving Password"
                                                                                                                message:@"We're helping you retrieve your password! Please check your email in a few minutes for a rescue link."
                                                                                                               delegate:self
                                                                                                      cancelButtonTitle:@"OK"
                                                                                                      otherButtonTitles:nil];
    [alert show];


      }failure:^( AFHTTPRequestOperation *operation , NSError *error ){

      if(!error){

     }
      }];


        }


DIOSUser.m

 + (void)userSendPasswordRecoveryEmailWithEmailAddress: (NSString*)email
                                              success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
                                              failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {

   NSString *path = [NSString stringWithFormat:@"user/%@/request_new_password", email];

    [[DIOSSession sharedSession] sendRequestWithPath:path method:@"POST" params:nil success:success failure:failure];
}
It would be better if this was externalised into a custom module instead of 'hacking' the services module. 

This is fine on my system

$definition = array(
  'user' =&gt; array(
    'operations' =&gt; array(
       ...
       'actions' =&gt; array( 
          ...
         'password_reset_email' =&gt; array(
         'access callback' =&gt; 'services_access_menu',
         'callback' =&gt; '_user_resource_password_reset_email',
         'args' =&gt; array(
          array(
                'name' =&gt; 'email',
                'optional' =&gt; FALSE,
                'source' =&gt; array('data' =&gt; 'email'),
                'type' =&gt; 'string',
                'description' =&gt; 'The email of the user whose password to reset.',
        ),
    ),


Function is

function _user_resource_password_reset_email($data) {
  global $language;


  $mail = _services_arg_value($data, 'data');
  $account = user_load_by_mail($mail);

  if (empty($account)) {
    return services_error(t('There is no user with email @email.', array('@email' =&gt; $mail)), 404);
  }

  // Mail one time login URL and instructions using current language.
  $mail = _user_mail_notify('password_reset', $account, $language);
  if (!empty($mail)) {
    watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' =&gt; $account-&gt;name, '%email' =&gt; $account-&gt;mail));
  }
  else {
    watchdog('user', 'There was an error re-sending password reset instructions mailed to %name at %email', array('%name' =&gt; $account-&gt;name, '%email' =&gt; $account-&gt;mail));
}

  $result = "success";
  return $result;
}