• Resolved clb2196

    (@clb2196)


    I found some suggestions in this forum for using hooks, I am trying to register users to a learndash course based on the form id. This DOES work correctly however… it is being triggered twice each time I register a user with that form and I can’t figure out why.

    add_action( 'user_registration_after_register_user_action', 'add_user_to_course_from_form', 10, 3 );
    function add_user_to_course_from_form( $valid_form_data, $form_id, $user_id ) {
    	if( $form_id == '60'){
    		
    		$course_ids = [19];
     
    		// Add user to each course
    		foreach ( $course_ids as $course_id ) {
    			ld_update_course_access( $user_id, $course_id, $remove = false );
    		}
    	}
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Action triggering twice?’ is closed to new replies.