diff --git src/bp-members/classes/class-bp-signup.php src/bp-members/classes/class-bp-signup.php
index b0f1d6673..3b70c5999 100644
|
|
class BP_Signup { |
111 | 111 | |
112 | 112 | // Cache missed, so query the DB. |
113 | 113 | if ( false === $signup ) { |
114 | | $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->members->table_name_signups} WHERE signup_id = %d AND active = 0", $this->id ) ); |
| 114 | $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->members->table_name_signups} WHERE signup_id = %d", $this->id ) ); |
115 | 115 | |
116 | 116 | wp_cache_set( $this->id, $signup, 'bp_signups' ); |
117 | 117 | } |
… |
… |
class BP_Signup { |
187 | 187 | * `registered`, `activated`. Default `signup_id`. |
188 | 188 | * @type string $order Order direction. Default 'DESC'. |
189 | 189 | * @type bool $include Whether or not to include more specific query params. |
190 | | * @type string $activation_key Activation key to search for. |
| 190 | * @type string $activation_key Activation key to search for. If specified, all other |
| 191 | * parameters will be ignored. |
| 192 | * @type int|bool $active Pass 0 for inactive signups, 1 for active signups, |
| 193 | * and `false` to ignore. |
191 | 194 | * @type string $user_login Specific user login to return. |
192 | 195 | * @type string $fields Which fields to return. Specify 'ids' to fetch a list of signups IDs. |
193 | 196 | * Default: 'all' (return BP_Signup objects). |
… |
… |
class BP_Signup { |
210 | 213 | 'order' => 'DESC', |
211 | 214 | 'include' => false, |
212 | 215 | 'activation_key' => '', |
| 216 | 'active' => 0, |
213 | 217 | 'user_email' => '', |
214 | 218 | 'user_login' => '', |
215 | 219 | 'fields' => 'all', |
… |
… |
class BP_Signup { |
231 | 235 | $sql = array( |
232 | 236 | 'select' => "SELECT DISTINCT signup_id", |
233 | 237 | 'from' => "{$bp->members->table_name_signups}", |
234 | | 'where' => array( |
235 | | 'active = 0', |
236 | | ), |
| 238 | 'where' => array(), |
237 | 239 | 'orderby' => '', |
238 | 240 | 'limit' => '', |
239 | 241 | ); |
240 | 242 | |
241 | | if ( empty( $r['include'] ) ) { |
| 243 | // Activation key trumps other parameters because it should be unique. |
| 244 | if ( ! empty( $r['activation_key'] ) ) { |
| 245 | |
| 246 | $sql['where'][] = $wpdb->prepare( "activation_key = %s", $r['activation_key'] ); |
| 247 | |
| 248 | // `Include` finds signups by ID. |
| 249 | } else if ( ! empty( $r['include'] ) ) { |
| 250 | |
| 251 | $in = implode( ',', wp_parse_id_list( $r['include'] ) ); |
| 252 | $sql['where'][] = "signup_id IN ({$in})"; |
| 253 | |
| 254 | /** |
| 255 | * Finally, the general case where a variety of parameters |
| 256 | * can be used in combination to find signups. |
| 257 | */ |
| 258 | } else { |
| 259 | |
| 260 | // Active. |
| 261 | if ( false !== $r['active'] ) { |
| 262 | $sql['where'][] = $wpdb->prepare( "active = %d", absint( $r['active'] ) ); |
| 263 | } |
242 | 264 | |
243 | 265 | // Search terms. |
244 | 266 | if ( ! empty( $r['usersearch'] ) ) { |
… |
… |
class BP_Signup { |
246 | 268 | $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 ); |
247 | 269 | } |
248 | 270 | |
249 | | // Activation key. |
250 | | if ( ! empty( $r['activation_key'] ) ) { |
251 | | $sql['where'][] = $wpdb->prepare( "activation_key = %s", $r['activation_key'] ); |
252 | | } |
253 | | |
254 | 271 | // User email. |
255 | 272 | if ( ! empty( $r['user_email'] ) ) { |
256 | 273 | $sql['where'][] = $wpdb->prepare( "user_email = %s", $r['user_email'] ); |
… |
… |
class BP_Signup { |
268 | 285 | if ( -1 !== $number ) { |
269 | 286 | $sql['limit'] = $wpdb->prepare( "LIMIT %d, %d", absint( $r['offset'] ), $number ); |
270 | 287 | } |
271 | | } else { |
272 | | $in = implode( ',', wp_parse_id_list( $r['include'] ) ); |
273 | | $sql['where'][] = "signup_id IN ({$in})"; |
274 | 288 | } |
275 | 289 | |
276 | 290 | // Implode WHERE clauses. |