Add user via PHP
-
I searched around and found this issue addressed in a few places but none exactly answered the questions / issues I have so I created a new post. i hope it is in the right place
First off I am a fairly adept programmer in a number of languages but consider myself maybe mediocre in php but learning quickly.
What I want to do is have a single login area on my community site and when a person creates a user on the top level I want to either create a user in the other products or use the same table. So when i create a user in my PHP code I want to call a script to create a user with the same info in WordPress. I have found and tried references to wp_create_user in the codex. i am using wordpress 3.0 and have multisite enbaled, so i also tried wpmu_create_user. These have not worked for me both give errors from other files here is the code
require_once(‘../wp-includes/registration.php’);
$ident = $_GET [‘pid’];
$gsql = “select username,password,email from accounts where ident = ‘$ident'”;
$result = mysql_query($gsql);
while($row = mysql_fetch_array($result)){$wpnum = wp_create_user( $row[‘username’], $row[‘password’], $row[’email’] );
}Originally this yeilded an error calling esc_sql so I added the followng
require_once(‘../wp-includes/formatting.php’);
to the top now it gives me the following error
Fatal error: Call to a member function escape() on a non-object in /home/workforc/public_html/campers/campblogs/wp-includes/formatting.php on line 2200
So the question(s)
1) have the wp_create_user and wpmu_create_user functions been depracted in 3.0 if so what is the replacment, i can seem to find any other fuunctions
2) If not are there other files I need to include to make this work, or what am I missing here.
Alternately or perhaps preferably I would rather just have WP use the table I have set up for the main accounts setup. I have seen an extrension that allowed this but have also read that it does not work in 3.0.
If neither is possiblle I might have to simply do an insert into the mysql table that WP uses and might need some guidance but would rather rely on it’s one API if possible as it will be way cleaner and less likely to crash everything.
- The topic ‘Add user via PHP’ is closed to new replies.