• Hi there,
    I recently installed the pro version and I set up a webhook for recieve data from a third party platform
    Then problem is when I tried to hook into the action it seems its not working
    This is my code
    add_filter( ‘wpwhpro/run/actions/custom_action/return_args’, ‘wpwh_fire_my_custom_logic’, 10, 3 );
    function wpwh_fire_my_custom_logic( $return_args, $identifier, $response_body ){

    $data=json_decode($response_body,true);//also tried without the json decode
    $body=$data[“payload”][“object”];
    $correo=$body[“email”];
    my_custom_function($correo);
    wp_mail( “[email protected]”,”Prueba hook”, “Prueba”);

    return $return_args;

    I decided to activate logs and see what I recieved, it looks like this

    {
    event: “user.invitation_accepted”,
    payload: {
    account_id: “YZwvfZtWSXq4diaCRhQPKQ”,
    object: {
    id: “04O-zwtsR9Cdb56s4kzPtA”,
    first_name: “Shannon”,
    last_name: “Chada”,
    email: “[email protected]”,
    type: 2
    }
    },
    event_ts: 1610135940479
    }

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Ironikus

    (@ironikus)

    Hey @mateoramos1997 – Thank you for reaching out, as well as for using our plugin. ??
    Your code is nearly correct – the only issue I can see is that you try to access the $response_body as an array while it’s an object.

    Try the following for getting the payload:
    $response_body->payload->object

    The json_decode is not necessary either.
    Feel free to let me know if you have further questions. ??

    Thread Starter mateoramos1997

    (@mateoramos1997)

    Hey @ironikus
    So if want to have the email as string
    should I acces using $data=$response_body->payload->object;

    then $em=$data['email'];

    I tried to do it that way and not worked

    Plugin Contributor Ironikus

    (@ironikus)

    Hey @mateoramos1997 – I assume you also need to use the object notation since it might be an object as well:

    $data->email

    I suggest you include the following to your code:

    ob_start();
    var_dump($response_body);
    $res = ob_get_clean();
    error_log( $res );

    This code will output the data in your debug.log file and shows you what type each of the data is.

    To understand more about the differences between the notation issue above, you can take a look at the following topic: https://stackoverflow.com/questions/30680938/how-can-i-access-an-array-object

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cant handle incoming webhook’ is closed to new replies.