Events Calendar Compatibility

8 Replies ·

  1. Are there any known issues with compatibility between Members and The Events Calendar plugin by Modern Tribe? And any fixes available?

    When viewing the calendar page I am getting a Members permission denied message (‘Sorry, but you do not have permission to view this content.’). When the Members plugin is disabled the calendar works as intended. There is no setting that is restricting access to the calendar page and none of the individucal events have content permissions set.

    Is there a filter or function available so that Members ignores anything to do with the events calendar?

    Thanks,
    Stu

  2. Justin Tadlock

    Most likely, this is due to The Events Calendar plugin incorrectly calling apply_filters( 'the_content' ) (or a similar core WP hook). Let me download it to see if I can find the issue.

  3. Justin Tadlock

    I wasn’t able to reproduce the issue. The “Events” page that shows the calendar worked fine for me using the Stargazer theme from this site. I need to be able to replicate the issue to see where it’s coming from. Can you provide more details, perhaps a step-by-step, of what you’re doing with the plugin? A link to the page on your site with the issue would also be helpful.

    With the above said, I am seeing some odd code in the events plugin where it’s intentionally overwriting some core WordPress global stuff. This could potentially be an issue because other plugins, like Members, relies on these globals.

    From src/Tribe/Templates.php, it looks like they’re overwriting the global post variable:

    $GLOBALS['post'] = self::spoofed_post();
    

    If that’s where the issue is coming from, Members (and many other plugins) are going to be receiving the wrong data.

  4. Stuart Matthews

    Hi Justin,

    Thanks for the quick reply.

    I am devloping a new theme for the site using Events Calendar Pro. There was already events on the site. The issue appears when in the photo view, also seems to happen when in list view. The month view seems to work ok. The photo view works with the 106 events we currently have on the site but when add a new event or restore a particular event from the bin the issue arises.

    We are not using the Members plugin for the events, it is used for a different section of the site, so none of the events have content permissions set. Is there a way to tell the members plugin to ignore events?

    I have tried changing to the twenty seventeen theme and still get the issue.

    I am going to upload the site to a dev domain and send you a link to the page. Do you have some way I can private message you logins?

  5. Justin Tadlock

    I don’t see a “photo” view option. All I see is month, list, and day. All of them work fine for me too with the TwentySeventeen theme.

    Is there a way to tell the members plugin to ignore events?

    Yes, it is possible to not utilize the “Content Permissions” feature with events. However, it won’t matter if the events plugin is messing up global variables. If that’s the problem, it would need to be corrected in the events plugin. Otherwise, you just wouldn’t be able to use the content permissions feature.

    Dropping this in your theme’s functions.php or a custom plugin file will disable content permissions for a post type:

    add_filter( 'members_enable_tribe_events_content_permissions', '__return_false' );
    

    I can almost guarantee that it won’t change anything on the front end though.

    I am going to upload the site to a dev domain and send you a link to the page. Do you have some way I can private message you logins?

    You can email me at justintadlock at gmail.com.

  6. Stuart Matthews

    The photo view is only available in the pro version of the events calendar.

    After checking all 107 events on the site, some of them did have permissions set. After removing permissions from all events the calendar (photo view) is now displaying correctly.

    Is there a way to have permissions set on events but still be able to view the archive page?

    You can recreate this by setting permissions on an event, logging out then viewing the events archive page.

    Thanks,

  7. Justin Tadlock

    The photo view is only available in the pro version of the events calendar.

    I’d need you to email me a copy of the pro version to test it. I’m using the version available from WordPress.org.

    After checking all 107 events on the site, some of them did have permissions set. After removing permissions from all events the calendar (photo view) is now displaying correctly…You can recreate this by setting permissions on an event, logging out then viewing the events archive page.

    I couldn’t recreate this with the non-photo views.

    Is there a way to have permissions set on events but still be able to view the archive page?

    This is how it works with literally every other plugin. 🙂

    It’s impossible for Members to mess with the entirety of an archive page if a plugin is using the standard archive method from WordPress simply because there’s no mechanism in WP to alter it.

    Everything, including this, is pointing toward the events plugin messing up the global $post variable. I just need to be able to recreate the scenario on my end to narrow down where the issue is in the events plugin. Once I can recreate it, I should be able to figure things out. Then, we can get in touch with the events plugin author and have them fix their code.

  8. Justin Tadlock

    It took me a while, but I finally managed to recreate the issue. I was only able to do this by going to Events > Settings > Display in the WP admin and changing the “Events template” setting to “Default Page Template”. It works fine with the setting at “Default Events Template”.

    I’ll look into why this is happening when selecting this option.

  9. Justin Tadlock

    This following is only an issue if you select “Default Page Template” for the option I mentioned above. If you select “Default Events Template,” this is a non-issue. So, you have a choice of changing that option or passing along the following information to the events plugin author.

    This must be fixed within The Events Calendar. It doesn’t appear to be something that’s a simple one-line change. There are several custom functions in the plugin that are all tied into this.


    This is the info that can be passed to the events plugin author:

    The issue comes down to this bit of code in the-events-calendar/src/Tribe/Templates.php (line 126):

    add_action( 'loop_start', array( __CLASS__, 'setup_ecp_template' ) );
    

    That code is calling the setup_ecp_template() method (below), which is spoofing the global post, a variable that 1,000s of plugins rely on (including Members). This is the starting point anyway.

    public static function setup_ecp_template( $query ) {
    
        do_action( 'tribe_events_filter_the_page_title' );
    
        if ( self::is_main_loop( $query ) && self::$wpHeadComplete ) {
            // on loop start, unset the global post so that template tags don't work before the_content()
            add_action( 'the_post', array( __CLASS__, 'spoof_the_post' ) );
    
            // on the_content, load our events template
            add_filter( 'the_content', array( __CLASS__, 'load_ecp_into_page_template' ) );
    
            // remove the comments template
            add_filter( 'comments_template', array( __CLASS__, 'load_ecp_comments_page_template' ) );
    
            // only do this once
            remove_action( 'loop_start', array( __CLASS__, 'setup_ecp_template' ) );
        }
    }