Remove action from plugin in child theme functions.php

Home Forums Calendar Products Community Events Remove action from plugin in child theme functions.php

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1458573
    Dan
    Participant

    I have located an action in the Community Events plugin which I would like to remove. I do not want to do this directly in the plugin as any updates will overwrite these changes. When I try and remove the action in my child theme’s functions.php, it is not working. The action I am trying to remove is as follows (line 118 of plugins/the-events-calendar-community-events/src/Tribe/Event_Form.php):

    add_action( ‘tribe_events_date_display’, array( $this, ‘loadRecurrenceData’ ) );

    The action is added within a class which has led me to follow the instructions on this page: https://mekshq.com/remove-wordpress-action-filter-class/

    However, the class object instance doesn’t appear to be in a global variable in the plugin meaning that I have no access to it outside of the class. Could you advise please how I can overcome this problem?

    Thank you.

    #1460243
    Victor
    Keymaster

    Hi Dan!

    Thanks for reaching out to us! Let me help you with this topic.

    First, please let me note that we are fairly limited in how much support we can give for custom development questions like that.

    That said, we always like helping out and at least point users into the right direction as much possible.

    Try using the following code to remove that action:

    remove_action( 'tribe_events_date_display', array( 'Tribe__Events__Community__Event_Form', 'loadRecurrenceData' ) );

    Does it work for you? Please let me know. 🙂

    Best,
    Victor

    #1460709
    Dan
    Participant

    Hi Victor,

    Thanks for your reply. Since contacting you, I discovered there is a recurrence.php template which I can override in my child theme and use to remove the relevant code in the front-end. This is a much simpler solution.

    I did previously add the remove_action code that you supplied to my child theme functions file but this didn’t work for some reason. It may have been to do with the ordering as obviously it can’t be removed before it’s been added!

    Anyway, the issue is now resolved so thank you for your help.

    Kind regards,
    Dan

    #1460720
    Victor
    Keymaster

    Hi Dan!

    I’m sorry the code didn’t work for you, but super glad you could find a solution with a template override. That’s a great approach.

    Thanks for following up to let me know about it.

    I’ll close this thread now, but feel free to open a new topic if anything comes up and we’ll be happy to help 🙂

    Best,
    Victor

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Remove action from plugin in child theme functions.php’ is closed to new replies.