3

I'm currently working with a Learn Management System and students can earn certificates after they completed a course. This certificate gets generated and has an "action hook" hooked to it, so i can hook in to modify it. My problem is now with the debugging: Every time i want to test my hook i have to create a user and let them complete the course. Has anyone an idea how to trigger the action manually? This would reduce the debugging time drastically. Thank you

1
  • you can just do do_action("name_of_action");
    – mmm
    Commented Oct 23, 2017 at 16:34

1 Answer 1

4

Use do_action, you can just:

do_action( 'my_action');

if your action has a callback function that need arguments say:

function my_callback( $an_array ){
  //use the array for something here
   var_dump($an_array);
}
add_action( 'my_action', 'my_callback' );

you can specify it in the do_action like this:

do_action( 'my_action', array( 'array_for_callback') );
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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