filter rss feed by organizer

Home Forums Calendar Products Events Calendar PRO filter rss feed by organizer

  • This topic has 11 replies, 4 voices, and was last updated 7 years ago by Matt.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1243636
    Matt
    Participant

    Hi, I am looking to filter the RSS feed by organizer, I have had support before on this matter and i was given the following code snip (see below), but i have been getting feedback that it’s not filtering, on closer inspection I can see its building the feed but not filtering by organizer, can you help?

    example link: https://www.cornwall.ac.uk/events/whats-on/feed/?organizer=7 (this should return one event)


    // Example URL [site url]/events/feed/?organizer=6

    /* Tribe, get feed by organizer ID */
    function tribe_alter_feed ( $query ) {

    if ( !is_feed() || !tribe_is_event_query() ) return;

    // set organizer if passed
    if ( isset ($_REQUEST['tribe_organizer']) ) $query->set('tribe_organizer', (int)$_REQUEST['tribe_organizer']);

    }
    add_action( 'pre_get_posts', 'tribe_alter_feed' );

    #1245142
    Barry
    Member

    Hi Matt,

    I’m sorry to hear that isn’t working for you.

    Based on a quick look, the snippet is looking for something like ?tribe_organizer=7 in the URL whereas in your example the URL has ?organizer=7 at the end (the tribe_ prefix is missing).

    Might that explain things?

    #1245144
    Matt
    Participant

    Hi Barry,
    Thanks for getting back to me.
    I did try replacing the parameter with tribe_organizer=7 but then I get the error: ‘ERROR: This is not a valid feed.’
    here is the full url I am using: https://www.cornwall.ac.uk/events/whats-on/feed/?tribe_organizer=7

    #1245327
    Barry
    Member

    Oh dear!

    I can take another poke at this but can’t promise anything, I’m afraid. Even if that snippet was originally provided by one of the team, customization work is something we’re not always able to assist with — especially at times where we are dealing with high volumes of support requests.

    That said, do bear with me and I’ll try to circle back to this as soon as I can ๐Ÿ™‚

    #1246404
    Nico
    Member

    Hey Matt,

    Thanks for the patience while I reviewed this issue by Barry’s request. Looking into the issue I found the same notice for your default feed and the event feed too:

    https://www.cornwall.ac.uk/feed/
    https://www.cornwall.ac.uk/events/feed/

    Does this still happens when you remove the snippet? If that’s the case then there’s an existing issue with feeds on the site that you’ll need to resolve first. You can follow the instructions detailed in our themer’s guide.

    Hope this helps,
    Best,
    Nico

    #1246744
    Matt
    Participant

    Hi Nico,
    you might need a bit of background to our setup we are running a WP network with a dedicated event site so the structure is currently [network-base-url][subsite][event calendar prefix]
    so the url that works is https://www.cornwall.ac.uk/events/whats-on/feed/

    so on that url the feed seems to be working (with no filters)

    Cheers

    #1247314
    Nico
    Member

    Thanks for clarifying Matt!

    Give me some time to set up a multisite install and give this a try. I coded the snippet for a single site install so it might not work on the network.

    In the meantime it would be great if you could share your system information with me so I can see if the plugins are up to date in your site (I’ll test the snippet with latest version of the products).

    Best,
    Nico

    #1249846
    Matt
    Participant

    This reply is private.

    #1256874
    Nico
    Member

    This reply is private.

    #1257146
    Matt
    Participant

    Hi Nico,
    Thanks for taking the time to look at this for me, I spent a bit of time looking into the problem and think I have cracked it! here is the updated code incase it helps anyone else:

    // Example URL [site url]/events/feed/?organizer=6
    
    /* Tribe, get feed by organizer ID */
    function tribe_alter_feed ( $query ) {
    
        if ( !is_feed() || !tribe_is_event_query() ) return;
        // set organizer if passed
        if ( isset ($_REQUEST['organizer']) ){
    
    		//Get original meta query
    		$meta_query = $query->get('meta_query');
    	
    		//Add organizer meta query to the original meta queries
    		$meta_query[] = array(
    							'key'=>'_EventOrganizerID',
    							'value'=> (int)$_REQUEST['organizer'],
    							'compare'=>'=',
    						);
    		$query->set('meta_query',$meta_query);
    	 	//print_r($query);
    	}
    }
    add_action( 'pre_get_posts', 'tribe_alter_feed' );

    Thanks again.
    Matt

    #1257299
    Nico
    Member

    Thanks so much for the solution Matt! You did a great job here ๐Ÿ™‚

    Iโ€™ll go ahead and close out this thread, but if you need help with anything else please donโ€™t hesitate to create a new one and we will be happy to assist you.

    Best,
    Nico

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘filter rss feed by organizer’ is closed to new replies.