• 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”, 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
    [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/

Viewing 1 replies (of 1 total)
  • 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.