The Sensei LMS single-course.php template has this action:

<?php

  /**
   * Hook inside the single course post above the content
   *
   * @since 1.9.0
   *
   * @param integer $course_id
   *
   * @hooked Sensei()->frontend->sensei_course_start     -  10
   * @hooked Sensei_Course::the_title                    -  10
   * @hooked Sensei()->course->course_image              -  20
   * @hooked Sensei_Course::the_course_enrolment_actions -  30
   * @hooked Sensei()->message->send_message_link        -  35
   * @hooked Sensei_Course::the_course_video             -  40
   */
  do_action( 'sensei_single_course_content_inside_before', get_the_ID() );

  ?>

I want to remove the_course_video and added this to functions.php:

add_action('template_redirect', function() {

    remove_action('sensei_single_course_content_inside_before', array( Sensei()->course, 'the_course_video' ), 40, 1);


    add_action('sensei_single_course_content_inside_before', array( Sensei()->course, 'the_course_video' ), 1, 1 );
}, 11 );

This adds the video with the add_action but doesn’t remove it with remove_action.

1 Answer
1

Just add below code in functions.php for remove action.

add_action( 'init', 'remove_hooks', 11 );
function remove_hooks(){   
 remove_action('sensei_single_course_content_inside_before',array('Sensei_Course','the_course_video'),40);
}

i have tested this and it is working for me. let me know if this works for you.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *