Prevent setting user cookies in admin or on login page
-
helpful/core/modules/class-core.php on line 89, the user cookie is being set on the init hook. Doing this causes the following exception: “Cannot modify header information – headers already sent” when visiting the login page.
I’m assuming we don’t want to set the user if they are on the login page or in the admin anyway, so we can modify the set_user_cookie method in the following way:
public function set_user_cookie() { if ((isset($GLOBALS['pagenow']) && $GLOBALS['pagenow'] === 'wp-login.php') || is_admin()) { return; } Helpers\User::set_user(); }
This also prevents the method from being called numerous times when visiting the WordPress admin, which is the case now.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Prevent setting user cookies in admin or on login page’ is closed to new replies.