Title: API create user error with empty result
Last modified: August 30, 2016

---

# API create user error with empty result

 *  [hershkoy](https://wordpress.org/support/users/hershkoy/)
 * (@hershkoy)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/api-create-user-error-with-empty-result/)
 * I am trying to create a user using the remote API operations with s2member PRO.
   
   I based my code on the sample that exists inside the “s2member pro api scripting”
   section. The code works 97% of the times. In some occasions it fails for no apparent
   reason.
 * $post_data = stream_context_create (array(“http” => array(“method” => “POST”,“
   header” => “Content-type: application/x-www-form-urlencoded”, “content” => “s2member_pro_remote_op
   =” . urlencode (serialize ($op)))));
 * $result = trim (file_get_contents (“[http://www.example.com/team/?s2member_pro_remote_op=1&#8221](http://www.example.com/team/?s2member_pro_remote_op=1&#8221);,
   false, $post_data));
    fwrite($file, “s2m api res: “.print_r($result,true).”\n”);
   if (!empty($result) && !preg_match (“/^Error\:/i”, $result) && is_array($user
   = @unserialize ($result))) { // } else { die(“API error reads: ” . $result); };
 * This gets into the “else” section of of the if, with empty “$result” (I don’t
   see no output). The output to the $file above the if also shows that the $result
   variable is empty.
 * An example $op input to the $post_data above.
 * op: Array
    ( [op] => create_user [api_key] => XXX_MY_KEY_XXX [data] => Array ([
   user_login] => blablauser [user_email] => [blabla@gmail.com](https://wordpress.org/support/topic/api-create-user-error-with-empty-result/blabla@gmail.com?output_format=md)[
   modify_if_login_exists] => 1 [first_name] => My Name [last_name] => [s2member_level]
   => 1 [s2member_subscr_id] => PG-12345678 [custom_fields] => Array ( [my_field_id]
   => Some value. )
 *  [s2member_notes] => Administrative notation. Created this User via API call.
   [
   user_pass] => 123456 [notification] => 1 )
 * )
 * How can I check what is wrong?
 * [https://wordpress.org/plugins/s2member/](https://wordpress.org/plugins/s2member/)

Viewing 1 replies (of 1 total)

 *  [mlmultimedia](https://wordpress.org/support/users/mlmultimedia/)
 * (@mlmultimedia)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/api-create-user-error-with-empty-result/#post-6264094)
 * I am having a similar issue. It works perfectly on WAMP, but on a live Linux 
   server I am seeing the error, “API error reads:”.
 * Stranglely the “Remote Operation: get_user (retrieve data about existing Users/
   Members)” API function works perfecty on both servers.
 * Are there any server requirements for the Remote Operation: create_user to work?
   Or is there any way to at least see an error message to help debug?
 * Thanks

Viewing 1 replies (of 1 total)

The topic ‘API create user error with empty result’ is closed to new replies.

 * ![](https://ps.w.org/s2member/assets/icon-256x256.png?rev=980067)
 * [s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions](https://wordpress.org/plugins/s2member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/s2member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/s2member/)
 * [Active Topics](https://wordpress.org/support/plugin/s2member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/s2member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/s2member/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)

 * 1 reply
 * 2 participants
 * Last reply from: [mlmultimedia](https://wordpress.org/support/users/mlmultimedia/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/api-create-user-error-with-empty-result/#post-6264094)
 * Status: not resolved