BP_XProfile_Field::get_children( bool $for_editing = false )

Get all child fields for this field ID.


Description Description


Parameters Parameters

$for_editing

(Optional) Whether or not the field is for editing.

Default value: false


Top ↑

Return Return

(array)


Top ↑

Source Source

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

	public function get_children( $for_editing = false ) {
		global $wpdb;

		// This is done here so we don't have problems with sql injection.
		if ( empty( $for_editing ) && ( 'asc' === $this->order_by ) ) {
			$sort_sql = 'ORDER BY name ASC';
		} elseif ( empty( $for_editing ) && ( 'desc' === $this->order_by ) ) {
			$sort_sql = 'ORDER BY name DESC';
		} else {
			$sort_sql = 'ORDER BY option_order ASC';
		}

		// This eliminates a problem with getting all fields when there is no
		// id for the object.
		if ( empty( $this->id ) ) {
			$parent_id = -1;
		} else {
			$parent_id = $this->id;
		}

		$bp  = buddypress();
		$sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_fields} WHERE parent_id = %d AND group_id = %d {$sort_sql}", $parent_id, $this->group_id );

		$children = $wpdb->get_results( $sql );

		/**
		 * Filters the found children for a field.
		 *
		 * @since 1.2.5
		 * @since 3.0.0 Added the `$this` parameter.
		 *
		 * @param object            $children    Found children for a field.
		 * @param bool              $for_editing Whether or not the field is for editing.
		 * @param BP_XProfile_Field $this        Field object
		 */
		return apply_filters( 'bp_xprofile_field_get_children', $children, $for_editing, $this );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.