• Resolved aykut1907

    (@aykut1907)


    Hello,

    i am currently trying to create an individual custom webhook, which is connected to Integromat.
    The trigger is triggered when the role of the user is changed in the backend of WordPress. At the moment everything works fine, but I have the problem if several user roles are changed at once. As a result I only get the last record of the user. What is the best way to proceed here so that I get all records of the users.

    Here is my code:

    add_action( ‘set_user_role’, ‘setUserRoleTrigger_init’, 10, 2 );
    function setUserRoleTrigger_init(){
    WPWHPRO()->delay->add_post_delayed_trigger(‘setUserRoleTrigger’, func_get_args() );
    }
    function setUserRoleTrigger( $user_id, $old_user_data ) {
    $user_data = (array) get_user_by( ‘id’, $user_id );
    $user_data[‘user_meta’] = get_user_meta( $user_id );
    $user_data[‘user_old_data’] = $old_data;

    do_action(‘wp_webhooks_send_to_webhook’,$user_data);
    }

    Thanks,
    Aykut1907

    • This topic was modified 6 years ago by aykut1907.
Viewing 1 replies (of 1 total)
  • Plugin Contributor Ironikus

    (@ironikus)

    Hey @aykut1907 – thank you a lot for your message.
    I’m afraid this is out of our scope since it is only about customizing something instead of really fixing an issue within our plugin.

    Apart from that, I’m still happy to give you some further guidance on what you can do 🙂

    The set user role only fires on the main role of the user. Since you add multiple roles, the other ones are additional and are usually added using the $user->add_role() function.

    You, therefore, should also use the add_user_role hook. Further details on this one is available here: https://developer.ww.wp.xz.cn/reference/hooks/add_user_role/

    Hope this helps!
    If you have further questions, please let me know. 🙂

Viewing 1 replies (of 1 total)

The topic ‘Custom webhook multiple result’ is closed to new replies.