I’m using the “password protected” plugin that will force users to login using a custom form and a custom password. I use this plugin to prevent access to the whole site from unwanted users.
Once done, if the first custom password management login is successfull, the code will signon on users accordingly:
/* begin my code */
$creds = array();
$creds['user_login'] = 'username';
$creds['user_password'] = 'thepassword';
$creds['remember'] = true;
$user = wp_signon( $creds, false );
if ( is_wp_error($user) )
echo $user->get_error_message();
// run it before the headers and cookies are sent
add_action( 'after_setup_theme', 'custom_login' );
/* end my code */
Should I modify this somehow?