SWPM cannot process this access request
-
Hello! I am developing a web application that uses WordPress as a backend (Headless). That is, I consume the WordPress resources and database from the app created in Vue with Node.js through the Rest API.
User creation is simple and I have it figured out. What I’m having problems with is the login.
Apparently (and according to WordPress) SWPM is blocking the login.
More details now:
- I send my app username and password to WordPress by Rest API using node-fetch (GET method).
- In WordPress I have an Endpoint inside a Custom Plugin (code below).
- This endpoint retrieves the URI parameters and sends them to wp_signon to sign in.
- If wp_signon succeeds in logging in, it returns the user’s data. If not, it returns an error array.
This is the custom endpoint en WP:
// Register REST API endpoints class Login_REST_API_Endpoints { /** * Register the routes for the objects of the controller. */ public static function register_endpoints() { // endpoints will be registered here register_rest_route( 'wp', '/login', array( 'methods' => 'GET', 'callback' => array( 'Login_REST_API_Endpoints', 'login' ), 'permission_callback' => '__return_true' ) ); } /** * @param WP_REST_Request $request Full data about the request. * @return WP_Error|WP_REST_Request */ public static function login( $request ) { $data = array(); $data['user_login'] = $request["email"]; $data['user_password'] = $request["password"]; $data['remember'] = true; $user = wp_signon( $data, false ); if ( !is_wp_error($user) ){ return $user; } else { return $error = json_encode(array('error' => true)); } } } add_action( 'rest_api_init', array( 'Login_REST_API_Endpoints', 'register_endpoints' ) );
So far so good. The problem appears when I activate the SWPM plugin.
I start getting this response (the asterisks are intentional, to hide the real info):
{ "code": "wp_die", "message": "<p>Warning! The Simple Membership plugin cannot process this access request to prevent you from accidentally logging out as WP admin.<\/p><p><a href=\"https:\/\/*********\/wp-admin\/profile.php\" target=\"_blank\">Click here<\/a>to see the profile with which you are logged in in this browser.<\/p><p>In this browser you have connected to the site as an administrator user. First, log out as WP admin and then you will be able to log in as a member.<\/p><p>Alternatively, you can use a different browser (where you are not logged in as an administrator) to test membership access.<\/p><p>Your frequent visitors or members will never see this message. This message is ONLY for the admin user.<\/p>", "data": { "status": 500 }, "additional_errors": [] }
And these are the headers when the error happens (the asterisks are intentional, to hide the real info):
Date: Sat, 11 Feb 2023 02:58:36 GMT Server: Apache Set-Cookie: swpm_session=52883ad4e8ad887e7***************; path=/ X-Robots-Tag: noindex Link: <https://******/wp-json/>; rel="https://api.w.org/" X-Content-Type-Options: nosniff Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages, Link Access-Control-Allow-Headers: Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type Expires: Wed, 11 Jan 1984 05:00:00 GMT Cache-Control: no-cache, must-revalidate, max-age=0 Content-Length: 890 Connection: close Content-Type: application/json; charset=UTF-8
I already tried:
- Close all sessions.
- Delete cookies and cache.
- Deactivate plugin and activate them one by one.
- Test with different browsers.
- Try with Insomnia.
And nothing works.
The only thing I have noticed is that when SWPM is disabled, the request is successful (code 200).
Could you please give me some idea of what might be going on and how I could fix it?
In use:
- SWPM 4.2.4.
- WP 6.1.1.
- The topic ‘SWPM cannot process this access request’ is closed to new replies.