Hi again Brajesh
From further research, it seems that em_content_pre only works for Events Manager’s pre-assigned pages so I thought I’d take a look to see if I could get pre_get_posts to work instead. On that basis, I came up with the following code to exclude group events from appearing on the user profile events tab as follows –
function my_exclude_groups ( $q ) { // if ( still need to add criteria to make sure we're on the right page ) { $meta_query = [ 'relation' => 'or', [ 'key' => '_group_id', 'compare' => 'NOT EXISTS',] ]; $q->set('meta_query', $meta_query ); // } } add_action( 'pre_get_posts', 'my_exclude_groups' );
This feels like a convoluted way of doing things ie. if I’m understanding correctly, Events Manager is overriding the BuddyBlog Pro filter and I’m then needing add that back into the query, but it does seem to be working so far at least. Would you agree this is an appropriate approach?
With very many thanks in advance.
NikHi Nik,
Thank you for the reply.you are quiet right about that filter not being useful.
BuddyBlog pro is not applying any filter. we are creating a custom query and post loop. This is a straightforward task. It seems that the event manager is sniffing the query using some hook for their post type and applying their scope.
The solution is to look into events manager and find what is the change that they are applying. I will still need some time for it. In the mean time, you can request their team for guidance.
Regards
BrajeshHi Brajesh
Thank you again.
1. I will certainly see if I can get any reply from the EM team but just to make sure I am asking the right questions, can you possibly confirm my understanding that BuddyBlog Pro is creating a custom query and loop but EM is somehow overriding that and what I’m looking for is a way to remove their scope entirely?
2. If that’s not possible,would an alternative approach be to use either pre_get_posts or possibly em_events_build_sql_conditions filters to add in the necessary conditions required by BuddyBlog Pro or perhaps there is some reason why that’s not a practical/advisable method?
I really do appreciate your patience with this. It’s a dealbreaker for this project so just have to get it working somehow 😉
Regards
NikHi Nik,
1. yes, Please tell them that we are using WP_Query/query_posts() for creating custom query inside the BuddyPress Profile Tab and EM is overriding that for the the event specific post type.2. Please wait for their answer.
If you don’t a receive a reply from them by this weekend, I will look into their plugin.
Regards
BrajeshHi Nik,
Thank you for the patience.Please try using this ro remove their scope on our pages.
function bblcustom_disable_em_scope() { if ( ! class_exists( 'EM_Event_Post' ) || ! method_exists( 'EM_Event_Post', 'parse_query' ) ) { return; } $priority = has_action( 'parse_query', array( 'EM_Event_Post', 'parse_query' ) ); if ( $priority ) { remove_action( 'parse_query', array( 'EM_Event_Post', 'parse_query' ), $priority ); } } add_action( 'bbl_groups_pre_container_contents', 'bblcustom_disable_em_scope' );
You can put this code in your bp-custom.php
I have not tested this code but this should remove the scope. Can you please tell me if it worked or not?
Regards
BrajeshHi Brajesh
Thank you so much for getting back to me on this.
I’ve now tested and can advise as follows –
Group Profile – issue seems to be fixed here ie. only the relevant group events are shown.
Personal Profile – still seem to have a problem here as events tab is showing both personal AND group events of which the user is the authorIn addition to the above, I have a couple of queries as follows –
Is there any way of screening out past events from the tabs? (Events Manager handles this for their own BuddyPress tabs but presumably we’re now removing that filter so is there a way of adding it back in?)
Will the code you have provided affect the Events Manager calendar, especially with regard to searches etc?
With many thanks again… this is definitely a step in the right direction but still not quite there yet.
Warm regards
Nik
You must be logged in to reply to this topic.