I'm working on a custom login page plugin. I'm trying to figure out how to log the user in without creating "headers already sent" errors.
I was calling wp_signon
directly after the user clicked "login," but quickly found that this approach yields "headers already sent" errors. I've switched to using hooks:
private function attemptLogin() {
add_action( 'after_setup_theme', array( $this->Cms, 'authenticateUser' ), 10, 2 );
do_action( 'after_setup_theme', $_POST['username'], $_POST['password'] );
}
But, as you've probably guessed, this yields the same errors since I'm still, in essence, executing the login immediately.
How can I leave the hook to run on its own schedule to avoid errors, while still making the user's credentials available to it?
I've searched both Google and this site for the answer to no avail. The closest to an answer I've found is this, but I'm still unsure how to implement the advice while still passing the user's credentials.
'after_setup_theme'
?