1

I'm trying to make a custom login action for my custom login page. Registration page with custom user meta works fine, but the problem with login page is that everything should work, but it doesn't and only god knows why.

add_action('formcraft_before_save', 'login_user_addon', 10, 4);

function login_user_addon($filtered_content, $form_meta, $raw_content, $integrations)
{
    global $fc_final_response;

    foreach ($raw_content as $key => $value) {
        if ( $value['label'] == 'Adres e-mail klienta' )
        {
            $user_email_login = $value['value'];
        }
        if ( $value['label'] == 'Hasło klienta' )
        {
            $user_pass_login = $value['value'];
        }
}


  $user = get_user_by( 'email', $user_email_login );

  $creds = array(

    'user_login' => $user->user_login,
    'user_pass'  => $user_pass_login

  );

    $usr = wp_signon( $creds, false );

    if ( !is_wp_error( $usr ) ) { 
            wp_set_current_user ( $usr->ID );
            wp_set_auth_cookie  ( $usr->ID );      
    } else {
        $fc_final_response['failed'] = $user_pass_login;
    }
}

The hook up there looks for the value from the form fields and it works okay because it returns the password from the $user_pass_login field. I made it for testing because I thought that the field does not send the password.

The problem is that when I'm typing in the correct password and the correct user name, it gives an error password field is empty.

It's driving me crazy because it's a last step to go while it comes to my project and I'm stuck with possibly simplest problem ever.

Best regards, Christopher

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.