2

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.

3

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.

| improve this answer | |
  • Thank you - this works perfectly! – Neil Scott Aug 27 '19 at 9:32
  • You’re welcome! – Chetan Vaghela Aug 27 '19 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.