Title: Problem with wp_create_user
Last modified: August 20, 2016

---

# Problem with wp_create_user

 *  [fancymyreality](https://wordpress.org/support/users/fancymyreality/)
 * (@fancymyreality)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/problem-with-wp_create_user/)
 * Please be a little patient as I’m fairly new to wordpress architecture. I’m having
   an issue with the wp_create_user() function. I’m trying to create a custom registration
   form page for my site.
 * This code is what should execute after submit:
 *     ```
       <?php
       	include('./wp-blog-header.php');
   
       	$theUser = $_POST['theUser'];
       	$theEmail = $_POST['theEmail'];
       	$random_password = generate_random_password(12, false, false);
   
       	$user_id = username_exists( $theUser );
   
       	if ( !$user_id ) {
       		$user_id = wp_create_user( $theUser, $random_password, $theEmail );
       	} else {
       		$random_password = __('User already exists.  Password inherited.');
       	}
       }
       ```
   
 * Most of the code was copied from the wp_create_user() function reference page.
 * I get this error:
 * >  Fatal error: call to member function get_row() on a non-object in wp-includes/
   > capabilities.php on line 530
 * Removing the whole username_exist code creates this error:
 * >  Fatal error: call to member function escape() on a non-object in wp-includes/
   > formatting.php on line 2295
 * I’m not sure what my error is. Everything I find says there’s a problem with 
   my $wpdb but whether I use global $wpdb in any area of the code above it still
   doesn’t work.
 * Any help is greatly appreciated. Thanks.

The topic ‘Problem with wp_create_user’ is closed to new replies.

## Tags

 * [form](https://wordpress.org/support/topic-tag/form/)
 * [register](https://wordpress.org/support/topic-tag/register/)
 * [Registration](https://wordpress.org/support/topic-tag/registration/)
 * [user](https://wordpress.org/support/topic-tag/user/)
 * [wp_create_user](https://wordpress.org/support/topic-tag/wp_create_user/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [fancymyreality](https://wordpress.org/support/users/fancymyreality/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/problem-with-wp_create_user/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
