ACF_Field_User::render_field()publicACF 3.6.0

Renders the field input HTML.

{} Это метод класса: ACF_Field_User{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$ACF_Field_User = new ACF_Field_User();
$ACF_Field_User->render_field( $field );
$field(массив) (обязательный)
The ACF field.

Список изменений

С версии 3.6.0 Введена.

Код ACF_Field_User::render_field() ACF 5.10.2

function render_field( $field ) {

	// Change Field into a select.
	$field['type']    = 'select';
	$field['ui']      = 1;
	$field['ajax']    = 1;
	$field['choices'] = array();

	// Populate choices.
	if ( $field['value'] ) {

		// Clean value into an array of IDs.
		$user_ids = array_map( 'intval', acf_array( $field['value'] ) );

		// Find users in database (ensures all results are real).
		$users = acf_get_users(
			array(
				'include' => $user_ids,
			)
		);

		// Append.
		if ( $users ) {
			foreach ( $users as $user ) {
				$field['choices'][ $user->ID ] = $this->get_result( $user, $field );
			}
		}
	}

	// Render.
	acf_render_field( $field );
}