Reputation: 1
I am trying to remove an action within an existing WooThemes Sensei Class
global $woothemes_sensei;
remove_action( 'sensei_single_course_modules_before', array( $woothemes_sensei->modules, 'course_modules_title' ),20 );
remove_action( 'sensei_single_course_modules_content', array( $woothemes_sensei->modules, 'course_module_content' ),30 );
I am not sure what I am doing wrong? I think I am calling the correct class with the global variable. And the labels are correct? I've tried various priorities.
Thank you!
Upvotes: 0
Views: 938
Reputation: 26319
$this
has no context here. it only has context inside a classremove_action
must have the exact same priority as the add_action
that you are trying to removecourse-modules.php
template says exactly how the course_modules_title
action is being added/** * Hook runs inside single-course/course-modules.php * * It runs before the modules are shown. This hook fires on the single course page,but only if the course has modules. * * @since 1.8.0 * * @hooked Sensei()->modules->course_modules_title - 20 */ do_action('sensei_single_course_modules_before');
Sensei does not appear to be using a global and the modules class is accessed via Sensei()->modules
as hinted at in the template. Therefore something like the following should remove your actions:
function so_31590319_remove_sensei_actions(){
remove_action('sensei_single_course_modules_before',array( Sensei()->modules,'course_modules_title' ), 20);
remove_action('sensei_single_course_modules_content', array( Sensei()->modules,'course_module_content' ), 20);
}
add_action( 'sensei_single_course_modules_before', 'so_31590319_remove_sensei_actions', 10 );
Upvotes: 1