Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Emil8250

    (@emil8250)

    For the record, I’m using WordPress 5.2 with the “Hestia” theme.

    Moderator bcworkz

    (@bcworkz)

    What part of WP are you sending a POST request to? The REST API? The API requires proper authentication before POST requests will be honored.

    To create a user, you need at least username and email. User ID is not part of the data because WP auto-assigns IDs. If you have some other sort of ID data to save, it can be saved in user meta.

    Thread Starter Emil8250

    (@emil8250)

    I am trying to do a HTTP Post to a remote API, not wordpress’s own API.

    I want it to make the above post, when a new user registers in WP, so that the same account is created in my other system, if that makes sense?

    Moderator bcworkz

    (@bcworkz)

    Ah, I see. print_r the value returned by wp_remote_post(). The problem with print_r() or var_dump() is your browser may not be expecting output at this point, so the output is best captured and output to a log file. If you don’t want to fuss with a file write routine, you could simply email yourself the output. For example:

    $response = wp_remote_post( $args );
    wp_mail('[email protected]', 'Remote post data returned', print_r( $response, true ));

    If the returned data is a WP_Error object, the message it contains will give you a clue about the problem. If it’s an array of server response data, the POST was successful as far as this end is concerned and the issue is likely at the other end.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘functions.php changes does not apply’ is closed to new replies.