Answer the question
In order to leave comments, you need to log in
Why is the wp_signon() function on wordpress not authorizing?
Good afternoon!
I use the following code for authorization:
$user['user_login'] = $_POST['log'];
$user['user_password'] = $_POST['pwd'];
$user['remember'] = true;
$signon = wp_signon($user, false);
if (is_wp_error($signon)) echo $signon->get_error_message();
print_r($signon);
Answer the question
In order to leave comments, you need to log in
This code seems to need to be placed inside a function. And call the function itself before the engine sends the headers to the client. Like this:
function custom_login() {
$user['user_login'] = $_POST['log'];
$user['user_password'] = $_POST['pwd'];
$user['remember'] = true;
$signon = wp_signon($user, false);
if (is_wp_error($signon)) echo $signon->get_error_message();
//print_r($signon);
}
add_action( 'after_setup_theme', 'custom_login' );
Haven't worked with wordpress before. Now understood.
The code:
function custom_login() {
$user['user_login'] = $_POST['log'];
$user['user_password'] = $_POST['pwd'];
$user['remember'] = true;
$signon = wp_signon($user, false);
if (is_wp_error($signon)) echo $signon->get_error_message();
//print_r($signon);
}
add_action( 'after_setup_theme', 'custom_login' );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question