BP_Signup: get (大批$ args.=大批()的)
基于参数获取注册。
描述
参数
- $ args.
-
(大批的)(可选)检索所需注册的参数。
- '抵消'
(int)偏移量。默认为0。 - '数字'
(int)有多少人获取。默认值1。 - 'Usermsearch'
(布尔|字符串)是否搜索用户名。默认为false。 - 'orderby'
(细绳)按参数订购。默认'signup_id'。 - “秩序”
(细绳)订单方向。默认为“desc”。 - “包括”
(保龄球)是否包括更具体的查询参数。 - '激活码'
(细绳)激活关键字搜索。 - '用户登录'
(细绳)具体用户登录返回。 - “字段”
(细绳)哪个字段返回。指定“IDS”以获取注册ID列表。默认值:'全部'(返回bp_signup.对象)。
默认值:array()
- '抵消'
返回
(大批)
- “注册”
(大批)定位注册。(仅当IDS时领域
被设定为ids.
。) - '全部的'
(int)匹配参数的注册总数。
来源
文件:bp-members / classes / class-bp-signup.php
Public static function get($args = array()) {global $wpdb;(r = bp_parse_args美元args,阵列(“抵消”= > 0,“数量”= > 1,usersearch = > false,“orderby”= >“signup_id”、“秩序”= >“DESC”,“包括”= > false, activation_key ' => '', ' 用户_ ' => '', ' 字段' = > '所有'),' bp_core_signups_get_args ');// @todo whitelist sanitization if ($r['orderby'] !== 'signup_id') {$r['orderby'] = 'user_' . txt ');$ r(“orderby”);} $ r(“orderby”)= sanitize_title ($ r(“orderby”));数组$ sql = ();$ signups_table = buddypress() - >成员- > table_name_signups;$sql['select'] = " select * FROM {$signups_table}";数组$ sql (', '] = ();$sql['where'][] = "当前位置"; if ( empty( $r['include'] ) ) { // Search terms. if ( ! empty( $r['usersearch'] ) ) { $search_terms_like = '%' . bp_esc_like( $r['usersearch'] ) . '%'; $sql['where'][] = $wpdb->prepare( "( user_login LIKE %s OR user_email LIKE %s OR meta LIKE %s )", $search_terms_like, $search_terms_like, $search_terms_like ); } // Activation key. if ( ! empty( $r['activation_key'] ) ) { $sql['where'][] = $wpdb->prepare( "activation_key = %s", $r['activation_key'] ); } // User login. if ( ! empty( $r['user_login'] ) ) { $sql['where'][] = $wpdb->prepare( "user_login = %s", $r['user_login'] ); } $sql['orderby'] = "ORDER BY {$r['orderby']}"; $sql['order'] = bp_esc_sql_order( $r['order'] ); $sql['limit'] = $wpdb->prepare( "LIMIT %d, %d", $r['offset'], $r['number'] ); } else { $in = implode( ',', wp_parse_id_list( $r['include'] ) ); $sql['in'] = "AND signup_id IN ({$in})"; } // Implode WHERE clauses. $sql['where'] = 'WHERE ' . implode( ' AND ', $sql['where'] ); /** * Filters the Signups paged query. * * @since BuddyPress 2.0.0 * * @param string $value SQL statement. * @param array $sql Array of SQL statement parts. * @param array $args Array of original arguments for get() method. * @param array $r Array of parsed arguments for get() method. */ $paged_signups = $wpdb->get_results( apply_filters( 'bp_members_signups_paged_query', join( ' ', $sql ), $sql, $args, $r ) ); if ( empty( $paged_signups ) ) { return array( 'signups' => false, 'total' => false ); } // We only want the IDs. if ( 'ids' === $r['fields'] ) { $paged_signups = wp_list_pluck( $paged_signups, 'signup_id' ); } else { // Used to calculate a diff between now & last // time an activation link has been resent. $now = current_time( 'timestamp', true ); foreach ( (array) $paged_signups as $key => $signup ) { $signup->id = intval( $signup->signup_id ); $signup->meta = ! empty( $signup->meta ) ? maybe_unserialize( $signup->meta ) : false; $signup->user_name = ''; if ( ! empty( $signup->meta['field_1'] ) ) { $signup->user_name = wp_unslash( $signup->meta['field_1'] ); } // Sent date defaults to date of registration. if ( ! empty( $signup->meta['sent_date'] ) ) { $signup->date_sent = $signup->meta['sent_date']; } else { $signup->date_sent = $signup->registered; } $sent_at = mysql2date('U', $signup->date_sent ); $diff = $now - $sent_at; /** * Add a boolean in case the last time an activation link * has been sent happened less than a day ago. */ if ( $diff < 1 * DAY_IN_SECONDS ) { $signup->recently_sent = true; } if ( ! empty( $signup->meta['count_sent'] ) ) { $signup->count_sent = absint( $signup->meta['count_sent'] ); } else { $signup->count_sent = 1; } $paged_signups[ $key ] = $signup; } } unset( $sql['limit'] ); $sql['select'] = preg_replace( "/SELECT.*?FROM/", "SELECT COUNT(*) FROM", $sql['select'] ); /** * Filters the Signups count query. * * @since BuddyPress 2.0.0 * * @param string $value SQL statement. * @param array $sql Array of SQL statement parts. * @param array $args Array of original arguments for get() method. * @param array $r Array of parsed arguments for get() method. */ $total_signups = $wpdb->get_var( apply_filters( 'bp_members_signups_count_query', join( ' ', $sql ), $sql, $args, $r ) ); return array( 'signups' => $paged_signups, 'total' => $total_signups ); }
更新日志
版本 | 描述 |
---|---|
BuddyPress 2.0.0 | 介绍。 |