If using HyperDB, or any advanced database plugin that allows for Writer/Reader configurations, for your WordPress setup, you may notice a common issue with logins not working properly. The issue here is the latency from the Writer DB and the Read Replicas. To resolve this issue, just add a sleep for 1 second. I have this used on my production environments and the login issue is now gone.
\add_action('wp_login', 'delayLoginForDBReplicationLag'); /** * Due to the latency from Writer to Reader, we need to delay login so the user is properly logged in */ function delayLoginForDBReplicationLag() { sleep(1); }
Spread the love