BuddyDev

Search

[Resolved] Group Tabs Pro – modifying existing tab

  • Participant
    Level: Master
    Posts: 279
    NikB on #45520

    Hi Brajesh

    So sorry for another query but I am just wondering what is the best way to use the Group Tabs Pro in the following scenario –

    I’m using Events Manager which creates a new group tab titled “Events”.

    I want to amend things so that (ideally) there is a group tab titled “Events” with two sub navs (ie. list of events and add new event)

    If I understand correctly, I can’t add a second sub nav to the existing Events tab so I’m assuming I have to remove the existing tab and then create a new one?

    Here are the steps I took –
    1. Removed the existing Events tab using the code – bp_core_remove_subnav_item( groups_get_current_group()->slug, ‘events’ );

    2. Created a new tab in Groups Tabs Pro with the same slug ie. ‘events’.

    This works in so far as the subnavs I want are now appearing, however, the tab content generated by the Events Manager plugin is ALSO appearing above BOTH sub navs.

    Would you recommend using a different slug (that’s certainly an option although sticking to ‘events’ feels more logical) or should I just find a way of removing the Events Manager content instead? Or have I taken the wrong approach completely?

    Hope that makes sense and with many, many thanks in advance.

    Nik

  • Keymaster
    (BuddyDev Team)
    Posts: 24250
    Brajesh Singh on #45541

    Hi Nik,
    Thank you for the question.

    1. If the content is being shown for event manager, then it seems their screen callback might not have been removed correctly or there is some bug in how the event manager renders the content.

    The simple solution will be to use a different slug or you can debug further if you want to keep the same slug.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 279
    NikB on #45542

    Hi Brajesh

    Thank you for your thoughts… and you’re right (of course ;-)), I now realise that the code I was using to remove the tab added by Events Manager wasn’t actually working.

    The code I was using was an adapted version of something I’d found here ie.

    function buddydev_custom_disable_group_events() {
    
    	if ( ! bp_is_group() ) {
    		return;
    	}
    	$group_id = bp_get_current_group_id();
    	$user_id  = get_current_user_id();
    
    	bp_core_remove_subnav_item( groups_get_current_group()->slug, 'events' );
    }
    
    add_action( 'groups_setup_nav', 'buddydev_custom_disable_group_events' ); 

    Unfortunately, it seems that Events Manager doesn’t use ‘groups_setup_nav’ but instead runs the following –

    add_action( 'bp_init', array(&$this, 'setup_group_nav') );

    from within its own Events Manager component.

    I do appreciate this is probably straying rather far into custom coding (and I’m personally at a loss as to how I’d remove such an action) so I guess in this case I’d better settle for the “simple” (if less elegant) solution of using a different slug… well.. unless you have any better suggestions.

    Warm regards
    Nik

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2952
    Ravi on #45550

    Hello Nik,

    Please try the following code to remove the events subnav item added by the Events Manager in group navigation.

    
    add_action( 'bp_init', function () {
    
    	if ( ! function_exists( 'bp_em_load_core_component' ) || ! bp_is_active( 'groups' ) ) {
    		return;
    	}
    
    	bp_core_remove_subnav_item( groups_get_current_group()->slug, 'events' );
    }, 100 );
    
    

    Please give it a try.

    Regards
    Ravi

  • Participant
    Level: Master
    Posts: 279
    NikB on #45570

    Hi Ravi

    I’m pleased to say that seems to work perfectly… and I’ve learnt something too!

    With very many thanks to both you and Brajesh.

    Warm regards
    Nik

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2952
    Ravi on #45596

    Hello Nik,

    Thank you for the acknowledgement. I am glad that I could help.

    Regards
    Ravi

The topic ‘ [Resolved] Group Tabs Pro – modifying existing tab’ is closed to new replies.

This topic is: resolved