Re: Adding Users from Another Application
I’m adding users based on signup to my own application.
For instance a new users signs up to my site, I then use curl posts to add them to additional pieces of software such as our support desk, mailing list, and in this case community.
$fields_string = “”;
$url = ‘http://community.mysite.com/no-idea-what-url-to-post-to.php’;
$fields = array (‘signup_username’ => urlencode($username), ‘signup_email’ => urlencode($email), ‘signup_password’ => urlencode($password), ‘signup_password_confirm’ => urlencode($password), ‘field_1’ => urlencode($username), ‘signup_profile_field_ids’ => urlencode(1));
foreach($fields as $key => $value) {
$fields_string .= $key.’=’.$value.’&’;
}
rtrim ($fields_string, ‘&’);
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_POST, count ($fields));
curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields_string);
$results = curl_exec ($ch);
curl_close ($ch);
If there’s a better way, please advise, everything is on the same server so I can include specific files to do a more API style function, just can’t seem to find any reference material that tells me what I need to know.
I found a post on WordPress.org on using the
wp_create_user ($username, $password, $email)
function, but I can’t seem to find a way to implement it for an outside application.
There really needs to be an external API.
Anyway, appreciate the help
V