[How to] Add a User to WordPress Programmatically
In a recent development project, I had to add a user to WordPress programmatically because I had no WP user data but only access to FTP. If this is your case, here is the code I used to add myself to the WordPress users:
<?php /* Add user to wordpress programmatically */ $user_name = "wpadmin"; $user_email = "[email protected]"; $user_pass = "1234"; $user_id = username_exists( $user_name ); if ( !$user_id and email_exists($user_email) == false ) { $random_password = $user_pass; // Alternate : wp_generate_password( $length=5, $include_standard_special_chars=false ); $user_id = wp_create_user( $user_name, $random_password, $user_email ); } else { $random_password = __('User already exists. Password inherited.'); } print $random_password;