Hi i’m glad that you liked the plugin,
see this topic
i think it’s related to what you need.
Yes, Amin, could be. The trick of the low priority could be another way to achieve the same result as my commenting out the exit(); line.
In my case, however, I need a little more. I’d need a way to disable redirects completely.
Actually I’m registering new users ONLY via AJAX (and REST-API). Any redirect (if any at all) must be handled client-side. The PHP script must NOT send any other header (such as ‘redirect’) since the response to the AJAX call, with all the relevant headers, needs to be constructed within the end-point’s callback.
Any (potentially) redirecting header (like 30X) is very likely to trigger an error in the client, at least in Angular implementation.
A quick but clean fix would be, for instance, that no redirect is actually performed (no ‘redirect’ header is sent) if the “Redirect” field in the plugin’s settings is left empty. Or, maybe, redirect if and only if we’re not DOING_AJAX or DOING_REST_API.
In any case, thanks again for your job!
P.S.: I’ve also added this in the constructor
add_action( 'rest_api_init', function () {
register_rest_route( 'dornaweb/v1', '/email-verify/link/send', array(
'methods' => 'POST',
'callback' => function ($request) {
$user_login = sanitize_text_field($request->get_param('email'));
if ( empty( $user_login) )
{
return ['ok' => false];
}
$user = get_user_by( 'email', trim( $user_login ) );
if ( empty( $user ) )
{
return ['ok' => false];
}
$this->send_verification_link( $user->ID );
// Success
return ['ok' => true];
}
)
);
});