예제 #1
0
 /**
  * Calculate the search choices for the users
  *
  * @since 1.8
  *
  * @return array Array of user choices (value = ID, text = display name)
  */
 private static function get_created_by_choices()
 {
     /**
      * filter gravityview/get_users/search_widget
      * @see \GVCommon::get_users
      */
     $users = GVCommon::get_users('search_widget', array('fields' => array('ID', 'display_name')));
     $choices = array();
     foreach ($users as $user) {
         $choices[] = array('value' => $user->ID, 'text' => $user->display_name);
     }
     return $choices;
 }
 /**
  * Output the select to change the entry creator
  * @param int $form_id GF Form ID
  * @param array $entry    GF entry array
  * @return void
  */
 function add_select($form_id, $entry)
 {
     if (rgpost('screen_mode') !== 'edit') {
         return;
     }
     $users = GVCommon::get_users('change_entry_creator');
     $output = '<label for="change_created_by">';
     $output .= esc_html__('Change Entry Creator:', 'gravityview');
     $output .= '</label>
     <select name="created_by" id="change_created_by" class="widefat">';
     $output .= '<option value=""> &mdash; ' . esc_attr_x('No User', 'No user assigned to the entry', 'gravityview') . ' &mdash; </option>';
     foreach ($users as $user) {
         $output .= '<option value="' . $user->ID . '"' . selected($entry['created_by'], $user->ID, false) . '>' . esc_attr($user->display_name . ' (' . $user->user_nicename . ')') . '</option>';
     }
     $output .= '</select>';
     $output .= '<input name="originally_created_by" value="' . esc_attr($entry['created_by']) . '" type="hidden" />';
     echo $output;
 }