I’m running into an issue where I want to register new users into my WP from another page on my site (from another function outside of the WP environment), how do I go about doing that. Meaning I am integrating the WP Blog into my site and I want to be able to have people who register for my site automatically register for the WP Blog at the same time. I tried the following from one of my functions:
//this is declared OUTSIDE of any function for global scope
require BASEDIR .”/blog/wp-includes/wp-blog-header.php”;
$NiceName = $fname . ” ” . $lname;
$newMem = array(
‘user_login’ => $uname,
‘user_pass’ => $password,
‘user_nicename’ => $NiceName,
‘nickname’ => $NiceName,
‘first_name’ => $fname,
‘last_name’ => $lname,
‘display_name’ => $NiceName,
‘user_registered’ => date(”Y-m-d H:i:s”),
‘user_email’ => $email
);
wp_insert_user($newMem);
But it seems to conflict with my database for my site is throwing errors when I make any db calls after wp-blog-header.php has been included:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sytablev/public_html/index.php on line 109
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/sytablev/public_html/includes/classes/my_queries.class.php on line 734
Any ideas what I could do to get this to work? Thanks.