bp_ps_gender_setup( $fields )
Registers a Gender field in frontend and backend in advance search.
Description
Parameters
- $fields
-
(Required)
Return
(array)
Source
File: bp-core/profile-search/bps-xprofile.php
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | function bp_ps_gender_setup ( $fields ) { global $wpdb ; $exists_gender = $wpdb ->get_results( "SELECT COUNT(*) as count, id FROM {$wpdb->prefix}bp_xprofile_fields a WHERE parent_id = 0 AND type = 'gender' " ); if ( $exists_gender [0]-> count > 0 ) { $field = new BP_XProfile_Field ( $exists_gender [0]->id ); if ( empty ( $field ->id)) return $fields ; $options = array (); $rows = $field ->get_children (); if ( is_array ( $rows ) ) { foreach ( $rows as $row ) { if ( '1' === $row ->option_order ) { $option_value = 'his_' . $row ->name; } elseif ( '2' === $row ->option_order ) { $option_value = 'her_' . $row ->name; } else { $option_value = 'their_' . $row ->name; } $options [ stripslashes ( trim( $option_value ) ) ] = stripslashes ( trim( $row ->name ) ); } $f = new stdClass; $f ->group = __( 'Gender' , 'buddyboss' ); $f ->id = 'xprofile_gender' ; $f ->code = 'field_xprofile_gender' ; $f ->name = __( 'Gender' , 'buddyboss' ); $f ->description = __( 'Gender' , 'buddyboss' ); $f ->type = 'selectbox' ; $f ->format = bp_ps_xprofile_format( 'selectbox' , 'xprofile_gender' ); $f ->options = $options ; $f ->search = 'bp_ps_xprofile_gender_users_search' ; $fields [] = $f ; } } return $fields ; } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.