WPSEO_Sitemaps_Cache::invalidate_author()public staticYoast 1.0

Invalidate sitemap cache for authors.

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

Хуков нет.

Возвращает

true|false. True if the sitemap was properly invalidated. False otherwise.

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

$result = WPSEO_Sitemaps_Cache::invalidate_author( $user_id );
$user_id(int) (обязательный)
User ID.

Код WPSEO_Sitemaps_Cache::invalidate_author() Yoast 22.3

public static function invalidate_author( $user_id ) {

	$user = get_user_by( 'id', $user_id );

	if ( $user === false ) {
		return false;
	}

	if ( current_action() === 'user_register' ) {
		update_user_meta( $user_id, '_yoast_wpseo_profile_updated', time() );
	}

	if ( empty( $user->roles ) || in_array( 'subscriber', $user->roles, true ) ) {
		return false;
	}

	self::invalidate( 'author' );

	return true;
}