WPSEO_Register_Capabilities::map_meta_cap_for_seo_manager()publicYoast 1.0

Maybe add manage_privacy_options capability for wpseo_manager user role.

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

Хуков нет.

Возвращает

Строку[]. Filtered primitive capabilities required of the user.

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

$WPSEO_Register_Capabilities = new WPSEO_Register_Capabilities();
$WPSEO_Register_Capabilities->map_meta_cap_for_seo_manager( $caps, $cap );
$caps(string[]) (обязательный)
Primitive capabilities required of the user.
$cap(string[]) (обязательный)
Capability being checked.

Код WPSEO_Register_Capabilities::map_meta_cap_for_seo_manager() Yoast 24.0

public function map_meta_cap_for_seo_manager( $caps, $cap ) {
	$user = wp_get_current_user();

	// No multisite support.
	if ( is_multisite() ) {
		return $caps;
	}

	// User must be of role wpseo_manager.
	if ( ! in_array( 'wpseo_manager', $user->roles, true ) ) {
		return $caps;
	}

	// Remove manage_options cap requirement if requested cap is manage_privacy_options.
	if ( $cap === 'manage_privacy_options' ) {
		return array_diff( $caps, [ 'manage_options' ] );
	}

	return $caps;
}