Is it possible to show the calendar only for some groups and not in all groups

Hello,

Nice calendar you made. I am wondering if it is possible to show the calender only in self chosen groups.

Some groups of my site will not need a events calendar but some groups shoud have this possibility ...

Is it possible to show/unshow the calendar in the groups view>

Jap

  • Ash

    Hello @Danpajo

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    This is not currently possible out of the box, but I am marking this as a feature request.

    And for now, you can use this simple code to hide the calendar tab:

    function remove_group_options() {
        global $bp;
        $ids = array( 1, 2, 5, 16 );
        $id = $bp->groups->current_group->id;
        if( in_array( $id, $ids ) ){
    	?>
    	<style>
    	li#nav-calendar-groups-li{display: none}
    	</style>
    	<?php
        }
    
    }
    add_action( 'wp_head', 'remove_group_options' );

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Make sure, in $ids array, you need to put all group IDs where you don't want to show the calendar tab.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.