ACF_Field_User::ajax_query_init()publicACF 5.8.8

Runs during the AJAX query initialization.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$ACF_Field_User = new ACF_Field_User();
$ACF_Field_User->ajax_query_init( $request, $query );
$request(массив) (обязательный)
The query request.
$query(ACF_Ajax_Query) (обязательный)
The query object.

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

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

Код ACF_Field_User::ajax_query_init() ACF 6.0.4

function ajax_query_init( $request, $query ) {
	// Require field and make sure it's a user field.
	if ( ! $query->field || $query->field['type'] !== $this->name ) {
		$query->send( new WP_Error( 'acf_missing_field', __( 'Error loading field.', 'acf' ), array( 'status' => 404 ) ) );
	}

	// Verify that this is a legitimate request using a separate nonce from the main AJAX nonce.
	if ( ! isset( $_REQUEST['user_query_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( $_REQUEST['user_query_nonce'] ), 'acf/fields/user/query' . $query->field['key']) ) {
		$query->send( new WP_Error( 'acf_invalid_request', __( 'Invalid request.', 'acf' ), array( 'status' => 404 ) ) );
	}
}