Yoast\WP\SEO\Abilities\Infrastructure

Site_Representation_Field_Validators::validate_user_id │ public │ Yoast 1.0

Validates that the user to represent is one the current user could pick in the settings.

0 clears the setting and the current value can be kept, so neither is looked up.

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

Хуков нет.

Возвращает

string|null. A warning when the value cannot be saved, null otherwise.

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

$Site_Representation_Field_Validators = new Site_Representation_Field_Validators();
$Site_Representation_Field_Validators->validate_user_id( $value ): ?string;
$value(int) (обязательный)
The ID of the user to save.

Код Site_Representation_Field_Validators::validate_user_id() Yoast 28.8

public function validate_user_id( int $value ): ?string {
	if ( $value === 0 || $value === $this->options_helper->get( 'company_or_person_user_id' ) ) {
		return null;
	}

	if ( $this->can_select_user( $value ) ) {
		return null;
	}

	// A single warning for both a missing and a disallowed user, so it cannot be used to find out which users exist.
	return \__( 'The user to represent was not changed, because no user that you can select exists with the given ID.', 'wordpress-seo' );
}