• Resolved voldh

    (@voldh)


    Hi Ironikus, thank you very much for this great plugin!

    I would like to trigger a webhook custom action when a user completes a course in LearnDash. LearnDash has the following action that fires after the course is marked completed

    do_action( 'learndash_course_completed', array $course_data )

    Ref: https://developers.learndash.com/hook/learndash_course_completed/

    I don’t know how to integrate this action into the webhook custom action.

    Could you help me, please?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter voldh

    (@voldh)

    Hi there!

    I managed to solve it, it was much simpler than I imagined. I will post the solution here in case anyone needs it in the future.

    add_action(
        'learndash_course_completed',
        function ( $data ) {
     
            // ANY user completed Course 421
            if ( $data['course']->ID == 421 ) {
    
                $custom_data = array(
                    'user_id' => $data['user']->ID
                );
                $webhook_names = array(
                    'user-complete-course'
                );
                $http_args = array(
                    'blocking' => false //Set this to true to receive the response
                );
                
                $response = apply_filters( 'wp_webhooks_send_to_webhook_filter', array(), $custom_data, $webhook_names, $http_args );
            
                return '';
            }
     
        },
        20
    );

    Thank you!

    Plugin Contributor Ironikus

    (@ironikus)

    Hey @voldh – Thank you very much for your message, as well as for using our plugin.
    Glad to see you found a solution for your question – do reach out again in case you have any further questions, we are happy to help. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom action (LearnDash)’ is closed to new replies.