Yoast\WP\SEO\Abilities\Infrastructure
Site_Representation_Field_Validators::can_select_user
Checks whether the current user could pick a user to represent in the settings.
Like the user picker in the settings, which relies on the users REST endpoint, users who cannot list users can only pick users with published posts, so they cannot make any account, like an administrator's, the public face of the site.
Метод класса: Site_Representation_Field_Validators{}
Хуков нет.
Возвращает
bool. Whether the user can be picked.
Использование
// private - только в коде основоного (родительского) класса $result = $this->can_select_user( $user_id ): bool;
- $user_id(int) (обязательный)
- The ID of the user to represent.
Код Site_Representation_Field_Validators::can_select_user() Site Representation Field Validators::can select user Yoast 28.8
private function can_select_user( int $user_id ): bool {
if ( \get_userdata( $user_id ) === false ) {
return false;
}
// Users and their profiles are shared across the network, so only members can represent this site.
if ( \is_multisite() && ! \is_user_member_of_blog( $user_id ) ) {
return false;
}
if ( \current_user_can( 'list_users' ) ) {
return true;
}
return $this->has_published_posts( $user_id );
}