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

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

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.