How to add WordPress user using php code
Sometimes it’s necessary to create a new user on WordPress site using PHP code (for example not possible access to email and password doesn’t work, etc …)
$userdata['user_login']='demo'; $userdata['user_pass']='demo'; $userdata['user_email']='demo@demo.com'; $userdata['user_nicename']='demo'; $userdata['role']='administrator'; wp_insert_user( $userdata );
Drop the code in index.php of the site, or in functions.php file of the current wp theme via FTP, refresh any page of the site and then remove this script from the place you dropped it. Now it’s possible to login into the site using credentials: demo/demo.