Undefined function wp_hash_password() when instantiating wp_insert_user()
-
I’m inserting a user programmatically.
The problem (from googling) appears to be that the /wp-includes/pluggable isn’t loaded when the form calls the script.
<?php defined( 'ABSPATH' ) or die( 'Plugin file cannot be accessed directly.' ); $pldir=plugin_dir_path( __FILE__ ); require $pldir.'regHandler.php'; if($_POST['button109']){ // It's a new user registration/ $newuserdata=regHandler($_POST); }
In the regHandler.php:
<?php function regHandler($formData){ $email=$formData['email']; $returnVals['userid']=0; //$pass=wp_generate_password ( 12, false ); $user_id = wp_insert_user( array( 'user_login' => $email, 'user_pass' => $pass, 'first_name' => $formData['first_name'], 'user_nicename' => $formData['first_name'], 'last_name' => $formData['last_name'], 'user_email' => $email, 'display_name' => $formData['first_name'] . ' ' . $formData['last_name'], 'nickname' => $formData['first_name'] . ' ' . $formData['last_name'], 'role' => 'contributor' ) ); }?>
The error:
Fatal error: Call to undefined function wp_hash_password() in /hermes/bosnaweb14a/b1229/ipg/haroldwooduk/wp-includes/user.php on line 1874
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Undefined function wp_hash_password() when instantiating wp_insert_user()’ is closed to new replies.