Custom Fields
Re-Envisioned
Support General Password checks not working

  • Creator
    Topic
  • #16167
    Resolved badabingbreda
    Participant

    I’m having a bit of trouble working with the password field. I’m adding a pseudo login-form to a site where users can “login” to view forms added to their account.

    I’ve added a field called ‘company_login’ and ‘company_password’ to a CPT. In the database I checked that a hash has been stored as the password in the wp_postmeta table for the id.

    The code provided in the docs example doesn’t work however. using rwmb_meta( 'company_password' , $postid ) comes up empty handed, whereas get_post_meta( $postid , 'company_password' ) gives me the value stored in the database.

    However, comparing the wp_hash_password( $password ) === get_post_meta( $postid , 'company_password' )[0] isn’t returning true. They are of the same type, but not the same value. I’m a bit stumped on what is going wrong.

    Any ideas to what I am doing wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #16228
    badabingbreda
    Participant

    Ok, so I’m mildly disappointed that my question didn’t get a response but I found the answer myself.

    I made an error by omitting the config variable in rwmb_meta, which should have been:

    rwmb_meta( 'company_password' , array() , $postid )

    but it still didn’t work with the code provided in the docs.

    Changed it to:

    if ( wp_check_password( $password , rwmb_meta( 'company_password' , array() , $postid ) ) ) {
      // code when password checks
    }

    Please correct in the docs, I’m assuming it has never worked as described.

    #16231
    Anh Tran
    Keymaster

    I’m sorry for the delay. I missed your question. I’ll correct the docs. Thanks for your feedback!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.