Problem with wp_create_user (1 post)

  1. fancymyreality
    Posted 4 years ago #

    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:

    	$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.

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 4 years ago by fancymyreality
  • This topic is not resolved
  • WordPress version: 3.3.1