rest_application_password_check_errors

函式
rest_application_password_check_errors ( $result )
引數
  • (WP_Error|null|true) $result Error from another authentication handler, null if we should handle it, or another value if not.
    Required:
返回值
  • (WP_Error|null|true) WP_Error if the application password is invalid, the $result, otherwise true.
定義位置
相關方法
rest_application_password_collect_statusrest_add_application_passwords_to_indexrest_cookie_check_errorswp_is_application_passwords_available_for_userwp_is_application_passwords_supported
引入
5.6.0
棄用
-

rest_application_password_check_errors: 這個過濾鉤子允許開發者修改在檢查應用程式密碼的有效性時返回的錯誤。

當使用基於應用密碼的認證時,檢查是否有錯誤。

function rest_application_password_check_errors( $result ) {
	global $wp_rest_application_password_status;

	if ( ! empty( $result ) ) {
		return $result;
	}

	if ( is_wp_error( $wp_rest_application_password_status ) ) {
		$data = $wp_rest_application_password_status->get_error_data();

		if ( ! isset( $data['status'] ) ) {
			$data['status'] = 401;
		}

		$wp_rest_application_password_status->add_data( $data );

		return $wp_rest_application_password_status;
	}

	if ( $wp_rest_application_password_status instanceof WP_User ) {
		return true;
	}

	return $result;
}

常見問題

FAQs
檢視更多 >