Change user field value to value of another user field I manage a basketball league site with two main user roles, "commissioner" and "player". Every player on the site is assigned to both a Tuesday team (field_team) and a Friday team (field_team2) via a user field, which is editable by commissioners. Because of player absences and other variables, the teams are usually different by the end of the week, so there are also two additional fields, Tuesday default team (field_tuesday_default) and Friday default team (field_friday_default).

See below for an example of what my Tuesday games page looks like to commissioners:



We start each week with a clean slate, i.e., every player back with their default team. Currently, at the end of each week our commissioners have to manually edit every player's user account to get their Tuesday/Friday team values back to the default.

See below for what a player's edit account page looks like to commissioners:



The problem is that it takes a long time and it is very tedious for commissioners to manually edit every player's user account to make their team values equal to their default team values.

Is there a way to programmatically change every user in the "player" role's Tuesday team and Friday team field values to equal their Tuesday default team and Friday default team values? All my research thus far has come up empty and I'm really at a loss at this point. Ideally, I would like to put a nice, big reset button on the Tuesday/Friday games pages that will perform the reset. Any help would be appreciated! Thanks.
Yes

Programmatically you have to create a custom form with submit button as the only field, now inside the submit handler it will be 2 step process something as below

following code I have written just to give an idea, and assuming field names in a way you can relate. You have to do the tweaks to make it work for you

/**
  * Form Builder
 */
function _my_module_reset_team_selection($form, &amp;$form_state) {
  $form = array();
  $form['reset_options'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; 'Reset Options'
    '#options' =&gt; array(
      'both' =&gt; 'Reset Both Teams',
      'ft'   =&gt; 'Reset Friday Team',
      'tt'   =&gt; 'Reset Tuesday Team',
    )
  );
  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Reset',
  );
}

/**
 * Submit Handler for your custom form.
 * 2 step process 1. Find Users to Update. 2. Update :)
 */
function _my_module_reset_team_selection_submit($form, $form_state) {

  // Logic to decide if to reset both or any one
  // possible values as 'both'/'ft'/'tt'
  $reset = $form_state['input']['reset_options'];
  // Step1. Get All the Users who are part of any team.
  $users_to_reset = _my_module_get_users_to_reset($reset);
  if (is_array($users_to_reset) &amp;&amp; count($reset)) {
    // Step2. Update to Reset.
    switch ($reset) {
      case 'both':
        foreach ($users_to_reset as $user_to_reset) {
          // For better performance you can use field_attach_api here**
          // I am using user_save() process
          $user = user_load($user_to_reset);
          $user-&gt;field_tuesday[$user-&gt;lang][0]['value'] = '';
          $user-&gt;field_friday[$user-&gt;lang][0]['value'] = '';
          user_save($user);
        }

        break;
      case 'ft':
        foreach ($users_to_reset as $user_to_reset) {
          // For better performance you can use field_attach_api here**
          // I am using user_save() process
          $user = user_load($user_to_reset);
          $user-&gt;field_friday[$user-&gt;lang][0]['value'] = '';
          user_save($user);
        }
        break;
      case 'tt':
        foreach ($users_to_reset as $user_to_reset) {
          // For better performance you can use field_attach_api here**
          // I am using user_save() process
          $user = user_load($user_to_reset);
          $user-&gt;field_tuesday[$user-&gt;lang][0]['value'] = '';
          user_save($user);
        }
        break;
    }
  }
}



/**
  *  Helper Function to get list of users to reset.
  *  Allows you to reset any of two Tuesday Team or Friday Team or both.
 */
function _my_module_get_users_to_reset($reset='both') {
  $get_tt_users = array();
  $get_ft_users = array();
  if($reset != 'ft') {
    $get_tt_users = db_select('field_tuesday_team','tt')
                 -&gt;fields('tt',array(entity_id))
                 -&gt;condition('tt.entity_type','user',"=")
                 -&gt;execute()
  }               -&gt;fetchCol();
  if($reset != 'tt') {
    $get_ft_users = db_select('field_friday_team','ft')
                 -&gt;fields('tt',array(entity_id))
                 -&gt;condition('tt.entity_type','user',"=")
                 -&gt;execute()
                 -&gt;fetchCol();
  }
  $users_to_reset = array_unique(array_merge($get_tt_users,$get_ft_users));
  return $users_to_reset;
}