Пример #1
0
/**
 * Returns the ID for the field based on the field name.
 *
 * @package BuddyPress Core
 * @param string $field_name The name of the field to get the ID for.
 * @return int $field_id on success, false on failure.
 */
function xprofile_get_field_id_from_name($field_name)
{
    return BP_Xprofile_Field::get_id_from_name($field_name);
}
Пример #2
0
 public function pre_user_query($user_search)
 {
     global $wpdb;
     $where = '';
     if (!empty($_POST['start_date'])) {
         $date = new DateTime(sanitize_text_field($_POST['start_date']) . ' 00:00:00');
         $date_formatted = $date->format('Y-m-d H:i:s');
         $where .= $wpdb->prepare(" AND {$wpdb->users}.user_registered >= %s", $date_formatted);
     }
     if (!empty($_POST['end_date'])) {
         $date = new DateTime(sanitize_text_field($_POST['end_date']) . ' 00:00:00');
         $date_formatted = $date->format('Y-m-d H:i:s');
         $where .= $wpdb->prepare(" AND {$wpdb->users}.user_registered < %s", $date_formatted);
     }
     //search by last update time of BP extended fields
     if (isset($_POST['updated_since_date']) && $_POST['updated_since_date'] != '' && (isset($_POST['bp_field_updated_since']) && $_POST['bp_field_updated_since'] != '')) {
         $last_updated_date = new DateTime(sanitize_text_field($_POST['updated_since_date']) . ' 00:00:00');
         $this->updated_since_date = $last_updated_date->format('Y-m-d H:i:s');
         $this->field_updated_since = sanitize_text_field($_POST['bp_field_updated_since']);
         $field_updated_since_id = BP_Xprofile_Field::get_id_from_name($this->field_updated_since);
         $user_search->query_from .= " JOIN `wp_bp_xprofile_data` XP ON XP.user_id = wp_users.ID ";
         $where .= $wpdb->prepare(" AND XP.field_id = %s AND XP.last_updated >= %s", $field_updated_since_id, $this->updated_since_date);
     }
     if (!empty($where)) {
         $user_search->query_where = str_replace('WHERE 1=1', "WHERE 1=1 {$where}", $user_search->query_where);
     }
     #wp_die( self::pr( $user_search ) );
     return $user_search;
 }