• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

What is the mysql query to add a user in Wordpress

What is the mysql query to add a user in Wordpress?

The fields I need to get populated are:
FirstName, LastName, UserName,Password, Email, Phone Number, City, Zip
0
nainil
Asked:
nainil
2 Solutions
 
dr_linuxCommented:
INSERT INTO wp_users (user_login, user_pass, nicename, email, user_url, registered, display_name) VALUES ('username','userpass','nicename','email','user_url', 12/12/2011,'display_name')

Then to store the rest of the info you'll nead to look at that table and get the userid that was created then...

INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES (1,'Phone Number','number')

and keep doing an insert into that table for as many other pieces of info you want to keep on that user all in Name/Value pair for each row.

there are a few extra fields that i didn't include in the wp_user table but those are the main ones.  For a listing of the table structure check out...
http://codex.wordpress.org/Database_Description#Database_Diagram
0
 
nainilAuthor Commented:
Hi,

I use MD5 for the  password field. Will wordpress accept MD5 or does it need MD5 + Salt etc?
0
 
gwkgCommented:
Why not use wp_insert_user()?

 http://codex.wordpress.org/Function_Reference/wp_insert_user

You could use wp_hash_password() to hash the password.  

[in pluggable.php]
function wp_hash_password($password) {
      global $wp_hasher;
 
      if ( empty($wp_hasher) ) {
          require_once ( ABSPATH . 'wp-includes/class-phpass.php');
          // By default, use the portable hash from phpass
          $wp_hasher = new PasswordHash(8, TRUE);
      }
 
      return $wp_hasher->HashPassword($password);
  }

If you want to see exactly what wp_hash_password() does, look in wp-includes/class-phpass.php

http://lab.yukei.net/wp-code/nav.html?wp-includes/class-phpass.php.source.html
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now