A plugin has a public function as:

public function event_dashboard_handler() {
    $action = sanitize_title( $_REQUEST['action'] );
    $event_id = absint( $_REQUEST['event_id'] );
    try {
        switch ( $action ) {
            case 'duplicate' :
                $new_event_id = event_manager_duplicate_listing( $event_id );
            case 'delete' :
                wp_trash_post( $event_id );
    do_action( 'event_manager_my_event_do_action', $action, $event_id );

I want to change the duplicate switch case with my_own_function for which I am adding action as below but been unsuccessful.

function change_duplicate($action, $event_id) {
    if ($action['duplicate'] ) {
        $new_event_id = my_own_function( $event_id );
add_action( 'event_manager_my_event_do_action', 'change_duplicate');

Can anyone help where I am going wrong?

Read more here: Changing switch cases using add_action in wordpress


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: