0

Can you explain to me what the following line of code means?

if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {

This is because I see that this is where my code finds the hitch and fails to set the password correctly.

UPDATE:

It is normal that once the e-mail has been sent to the page, the following selection puts False and then ends up at $ user = false; ?

if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {

if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
    list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
    $user                      = check_password_reset_key( $rp_key, $rp_login );
    if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
        $user = false;
    }
} else {
    $user = false;
}

if ( ! $user || is_wp_error( $user ) ) {
    setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
    if ( $user && $user->get_error_code() === 'expired_key' ) {
        wp_redirect( site_url( 'prova/?action=lostpassword&error=expiredkey' ) );
    } else {
        wp_redirect( site_url( 'prova/?action=lostpassword&error=invalidkey' ) );
    }
    exit;
}

Thanks a lot to those who will help me.

0

If the cookie named $rp_cookie exists and if the colon character (:) in the cookie is not the first character, then…

  • Then I just can't understand why Wordpress password recovery doesn't work ... – Matteo Feduzi Sep 3 at 8:29
  • I updated the request, could you tell me help for this? Thanks a lot. – Matteo Feduzi Sep 3 at 8:37
  • Keep in mind that the WordPress authentication mechanisms, and all of WordPress, are used by millions of users on a daily basis and are thus highly trustworthy. If it is not working it is probably somewhere else in the chain. What, exactly, is failing? I suggest you start a new question describing what you expect to happen vs. what is actually happening, step by step, and I bet you'll get more helpful answers. – Ted Stresen-Reuter Sep 3 at 8:37

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.