When I use WP Cerber with a plugin that is having Ajax Login, such as WP Nextend Social Login, and Madara (a manga theme & plugin), the login function breaks.
These lines do not work in Ajax call
wp_set_current_user ( $user->ID, $user_data['user_login'] ); // Set the current user detail
wp_set_auth_cookie ( $user->ID ); // Set auth details in cookiedo_action( 'wp_login', $user->user_login, $user );
I have tested:
If I disable WP Cerber plugin, the login works
If I enable WP Cerber plugin, and use the above code in a test request (non-ajax), it works
So it is WP Cerber to prevent ajax user login. How can I fix this?
Before setting the current user and the associated cookies, make sure to authenticate the user using wp_signon(). If the authentication process is skipped or not completed correctly according to WordPress standards, WP Cerber will block the login attempt to prevent unauthorized access.
To find out why WP Cerber is interfering with your AJAX login, check the Activity Log to see what’s happening with failed login attempts. Here’s how: Reproduce the issue from your computer, go to the Activity Log, and click My IP to filter the events for your activity. Look for denied login attempts. If an attempt is blocked, the log entry will show the reason. To get more details, click the ellipsis icon shown in the log entry.
It seems that you are using a non-genuine (modified) version of WP Cerber, as the label “User session ended” shown in your screenshot does not exist in the original WP Cerber plugin. Anyway, it looks like you have enabled the limit on the number of allowed concurrent user sessions, and the user have reached this limit. For more details, you can check this guide: https://wpcerber.com/limiting-concurrent-user-sessions-in-wordpress/.
Thank you.
But do you have other idea to debug the issue? As I said, If I add the wp_signon call in a direct request (for example in the ‘init’ action), I was able to log in. But if the wp_signon is called via a ajax request, it does not work.
I’ve tested to login using the initial admin account (ID 1), it works. But if I created another admin account and test, he cannot login. (session or login cookie cannot be added)