In this post, I will teach you how you can remove the WordPress login shake effect.
You’ve probably noticed that, when logging in to WordPress, if your username or password is incorrect, the login form kind of shakes back and forth.
Here, we’ve got this add-action and a hook called login_footer and then hooked to that is a function called wp_shake_js.
Moving forward, and if you search wp-shake-js function you’ll find this code on line 344.
This is the code that actually fires up when an erroneous login occurred.
I find this annoying. Thankfully, WordPress gives us a way to make it stop. All we need to do is add back some action to this hook.
Please note that this feature is just aesthetic decision. You might find this irrelevant but for others don’t. So this should be made completely based on your personal preference.
Alright. Let’s keep going.
We just need to add this code to your theme’s functions.php file or in a site-specific plugin
Using the following snippet will let you remove the login shake effect when error occurs.
Basically what the code means is that, it unhook the function wp_shake_js from ever happening by adding the remove_action hook. As you can see highlighted on line 3
Now, to be able to make this remove action hook work, we need to execute this hook back to our login_footer.
And of course the function I want to hook to that is this wpms_remove_login_shake.
Once, that done. Save your changes.
So now if you go back to your website login page, and if you have an incorrect username or password there, you can see that the shake was actually removed.
I already added the above code but why it’s still shaking. Do you have any ideas how I could figure out the reason?
The reason being is that, you might be using an older version of WordPress. So, instead of using the login_footer, replace it with login_head.
If you’re WordPress version is earlier than 5.4, shall we say 5.3 and below this code don’t work. Use the login_head instead as you can see below.
So that’s it. At this point, we’ve added a very simple code snippet showing you how to customize your login page by removing the login shake effect of your WordPress website using some action hooks.