Skip to:
Content
Pages
Categories
Search
Top
Bottom

Attempting to write new user password to database

  • Hey guys,

    I have created a new sign up form as i need it to be a lot more complex than the standard wordpress sign up or even what register plus etc can provide. The problem I am having is when writing the password to the database.

    currently i am using
    `$password = wp_hash_password($_POST);`

    and then inserting that into the database in the password section of the wp_users database.. however that password then doesnt work when you go to login with it…

    oddly enough when i refresh the page using
    `echo wp_hash_password(‘test’);`
    i get a different hash displaying everytime..

    As I am using buddy press i figured it best go in here given the wordpress function reference says that the $wp_hasher information can be overwritten by plugins and i am assuming that is what is happening.

    Please help! i am trying to get this registration form up and running asap.

    Thanks in advance

Viewing 5 replies - 1 through 5 (of 5 total)
  • BuddyPress doesn’t interfere with user registration at that level. I think you’re almost certainly doing something wrong if you are needing to create your own hash for the password, etc. The authentication class is overridable, and most stuff can be done via the ‘authenticate’ action (I think that’s the name). I would rethink the approach you are taking, and do a bit more research — the wordpress.org forums may have had discussion about hooking into the registration process, and certainly the codex does.

    Hi Paul,

    im not wanting to create my own hash.. i just want to write the user information to the database without using the default bp_core_screen_signup function.. so i am using a database query to manually add the data to the wp_user database table..

    the problem is that the hashed password isnt correct..

    can you offer any suggestions as to why when you refresh the page when echoing `wp_hash_password(‘test’);` i get a different hash each time??

    here is an example

    Person A currently exists in the database.. password = ‘test’
    Person B creates a new account where i write wp_hash_password(‘test’); to the database

    Person A looks like this $P$BgZ1xZI/B6RJ9bngl.EnPRcCB34n/G.
    Person B looks like this $P$BotBsMWNHVnIElIOT9VGpax6cdXVgo.

    Person A can log in with password as ‘test’
    Person B cannot.

    if i overwrite Person B’s password field with the copied and pasted hash from Person A, Person B can now log in with password ‘test’

    managed to fix this issue by writing the following
    `$wpdb->query($wpdb->prepare(“INSERT INTO `wp_users` (user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_status, display_name) values (‘$user_login’, MD5(‘$user_pass’), ‘$user_nicename’, ‘$user_email’, ‘$user_url’, ‘$date_registered’, ‘$user_status’, ‘$user_display_name’)”));`

    note the MD5() around the $user_pass variable.. this appropriately hashes the password as it is entered into the database.

    just FYI

    No no no, there is absolutely no need to insert a user account with a direct SQL query

    any reason you’re not just using the standard wp_insert_user() function? what does buddypress do that’s different than the standard wordpress signup?

    I’m curious because I’m in the process of doing the same thing as the OP (although was planning on just using the default wordpress functionality, which I have working for my system – but the next step is to migrate the code so that it uses buddypress as well)…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Attempting to write new user password to database’ is closed to new replies.
Skip to toolbar