Help Desk

Hide/change URL of Events XML Feed

  • Posts: 52 Topics: 16
    | Permalink

    Hello,

    A client of our would like to hide or modify the URL of their Events Calendar feed to prevent competing websites from integrating it into their own calendars. Ideally they would still like to keep the URL accessible directly as they will potentially offer the feed to a small number of other websites on a per-case basis. The general idea is that the URL wouldn’t be so easily guessable as /feed. Do you know if this is possible?

    Thank you.

    Posts: 6240 Topics: 17
    | Permalink

    Hi Raymond!

    Thanks for getting in touch with us!

    I think it should be possible to accomplish that, but it would definitely require some custom coding.

    Do note that the events feed is accessible through a URL like yoursite.com/events/feed. You can learn more about the events feed in the following article > https://theeventscalendar.com/knowledgebase/events-rss-feed/

    We also have a great article that will get you started customizing the RSS feed, so you could use the code in it as a starting point > https://theeventscalendar.com/knowledgebase/customize-rss-feed/

    I hope that helps. Let me know if any follow up questions.

    Best,
    Victor

    Posts: 52 Topics: 16
    | Permalink

    Hi,

    Thanks for the update. I’ve gone through that article and a few others but I can’t find anything that discusses changing the main events feed URL itself. Do you have any suggestions for this?

    Posts: 6240 Topics: 17
    | Permalink

    Hi Raymond!

    I’m sorry for a bit of delay in getting back to you.

    As you may already know, we are fairly limited in how much support we can give for custom development questions like that.

    We can certainly point you in the right direction. I would suggest you take a look at the WordPress Rewrite API. Additionally, it would probably be a good idea to make use of the ‘tribe_events_rewrite_rules_custom’ hook you can find at /wp-content/plugins/the-events-calendar/src/Tribe/Rewrite.php

    Hope that helps!

    Best,
    Victor

    Posts: 52 Topics: 16
    | Permalink

    OK, thanks for the update. I’ve got part of the way their, and my main RSS feed now works correctly. However, the events feed just shows the following:

    <?xml version=”1.0″ encoding=”UTF-8″?><rss version=”2.0″
    xmlns:content=”http://purl.org/rss/1.0/modules/content/”
    xmlns:dc=”http://purl.org/dc/elements/1.1/”
    xmlns:atom=”http://www.w3.org/2005/Atom”
    xmlns:sy=”http://purl.org/rss/1.0/modules/syndication/”

    >
    <channel>
    <title>Comments on: </title>
    <atom:link href=”https://www.themotoringdiary.com/events/837325573feed/” rel=”self” type=”application/rss+xml” />
    <link>https://www.themotoringdiary.com</link&gt;
    <description>for Motoring and Motorsport Events</description>
    <lastBuildDate>Wed, 06 Dec 2017 12:06:51 +0000</lastBuildDate>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <generator>https://wordpress.org/?v=4.9.8</generator&gt;
    </channel>
    </rss>

    Any idea why this would be?

    Posts: 6240 Topics: 17
    | Permalink

    Hi Raymond!

    I’m not sure why that could be happening.

    Could you please share the code and feed URL you are using for your events so I can have a look? Perhaps I or any of the team members can find what could be wrong about it.

    Best,
    Victor

    Posts: 52 Topics: 16
    | Permalink

    Hi Victor,

    Thank you, that’s great. The code we are using is as follows:

    add_action( 'init', function()
    {
    add_feed( '837325573feed', 'do_feed_rss2' );
    });
    
    add_action( 'pre_get_posts', function( \WP_Query $q )
    {
    if( $q->is_feed( '837325573feed' ) )
        add_filter( 'option_rss_use_excerpt', '__return_false' );
    
     } );
    
     function remove_feed( $feedname ) {
        global $wp_rewrite;
    
        if ( in_array( $feedname, $wp_rewrite->feeds ) ) {
                $wp_rewrite->feeds = array_diff( $wp_rewrite->feeds, array( $feedname ) );
        }
    
        $hook = 'do_feed_' . $feedname;
    
        // Remove default function hook
        remove_all_actions( $hook );
        add_action( $hook, $hook );
    
        return $hook;
    }
    
    remove_feed( 'feed' );

    The events feed is here:

    https://www.themotoringdiary.com/events/837325573feed

    The regular WordPress feed is here:

    https://www.themotoringdiary.com/837325573feed

    Please let me know if you can shed any light on things!

    Thank you.

    Posts: 6240 Topics: 17
    | Permalink

    Hi Raymond,

    Thanks for sharing the code.

    I’ve tried it on my end and works exactly the same as in your site. It looks like the events are not being added to the new feed URL somehow, but I’m not able to identify why.

    I hope you can understand this is outside of our stated scope of support. I can certainly flag this to the team to have some feedback, however, we do need to prioritize support requests from other customers at this time. Although we can’t make any promises, if we have time and space to come back and help, we’ll be happy to do so.  Please let us know if you’d like to go this route so that you can be added to this queue.

    If you urgently need help with this, however, you may instead wish to consider working with a suitably skilled developer who can offer the additional level of support you require.

    Best,
    Victor

    Posts: 52 Topics: 16
    | Permalink

    Thanks for the update! Let me know how you get on.

    Posts: 6240 Topics: 17
    | Permalink

    Sure thing! I have added this to the queue.

    We’ll get back to you once we are able to have a look.

    Best,
    Victor

    Posts: 52 Topics: 16
    | Permalink

    Hi Victor,

    I just wondered if you’d had any progress with this at all?

    Posts: 18146 Topics: 17 Answers: 973
    | Permalink

    Hi Raymond,

    Sorry for the delay — once we place tickets in the custom dev queue I’m afraid they are not actively monitored (though we may change this going forward).

    The basic approach I’d recommend though is utilizing the tribe_events_pre_rewrite (action) hook. This will receive an object containing our rewrite rules and you can then modify them as needed by rebuilding the rules array.

    A simple search and replace of ‘feed’ with some other keyword probably won’t work by itself, however, unless you make supporting changes in WordPress’s query logic to map that new keyword back to RSS.

    Unfortunately, we’re experiencing very high demand for support and so are unable to spend further time on this request. To that end, I’m going to close it out. If you still need assistance here, it is probably best to reach out to a third party developer.

    Thanks for understanding (and if we can help with anything else, please do create a new ticket).

    | Permalink