BP_XProfile_Field_Type_Gender::is_valid( int $values = '' )

Check if valid.

Description

Parameters

$values

(int) (Optional) post id.

Default value: ''

Return

(bool)

Source

File: bp-xprofile/classes/class-bp-xprofile-field-type-gender.php

	public function is_valid( $values = '' ) {

		global $wpdb;

		if ( empty( $values ) ) {
			return true;
		}

		$split_value = explode('_', $values );
		if ( 2 === count( $split_value ) ) {
			if ( '' !== $split_value[1] && '' !== $split_value[0] ) {
				$get_parent_id_of_gender_field = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}bp_xprofile_fields WHERE type = %s AND parent_id = %d ", 'gender', 0 ) );
				$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$wpdb->prefix}bp_xprofile_fields WHERE type = %s AND name = %s AND parent_id = %d ", 'option', $split_value[1], $get_parent_id_of_gender_field ) );
				if ( '1' === $count ) {
					return true;
				} else {
					return false;
				}
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

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.