Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bpfr_custom_group_default_tab'

Viewing 9 results - 1 through 9 (of 9 total)
  • Author
    Search Results
  • #256498
    danbp
    Moderator

    I use that function bpfr_custom_group_default_tab and it works.
    Have you replaced the group slug to yours in ‘case’ ? This must fit the exact slug, the one you see by mouse over the group name in the bottom left corner of your brower (and normally in the browser’s address bar).

    Please ask one question at a time. Make an effort to be clear. It’s difficult to follow your post !

    – I want to do this on profile: details, item names…

    – I want to do this on groups: details, item names…

    NB 1: if you want to change the landing tab for ALL groups, you can use:

    
    define( 'BP_GROUPS_DEFAULT_EXTENSION', 'members' );

    With this, all groups will use the group members directory as landing tab instead the group activity.
    If you want a different landing tab for each group, use the snippet and don’t use define.

    Changing Internal Configuration Settings

    NB 2: the tab name has no influence on the landing tab. The name and the slug are handled separately, precisely because of that

    NB 3: where you put functions in bp-custom has no importance.

    #256490
    danbp
    Moderator

    The Home tab is the default one. If you remove that tab, BP has no way to know where to output the other group tabs content. If you remove Home(aka activity) you should define another landing tab.

    But when you want to modify groups, you shouldn’t define ‘profile’, but ‘groups’. (read what you wrote!)
    For the profile landing tab, see this codex page.

    For groups, you can try this snippet. This let you define a different landing tab for each of your groups (not profile, ok ?). 😉

    function bpfr_custom_group_default_tab($default_tab){
    	/**
    	 * class_exists() is recommanded to avoid problems during updates 
    	 * or when Groups Component is deactivated
    	 */
    	if ( class_exists( 'BP_Group_Extension' ) ) : // 
    	
    	$group=groups_get_current_group();//get the current group
    	
    	if(empty($group))
    	return $default_tab;
    	
    	switch($group->slug){
    		
    		case 'kill-bill': // group name (use slug format)
    		$default_tab='forum';
    		break;
    		
    		case 'groupe-2014':
    		$default_tab='members';
    		break;
    		
    		default:		
    		$default_tab='home';// the original default landing tab
    		break;
    		
    	}
    	
    	return $default_tab;
    	
    	endif; // end if ( class_exists( 'BP_Group_Extension' ) )
    }
    add_filter('bp_groups_default_extension','bpfr_custom_group_default_tab');
    #248587
    ma3ry
    Participant

    This is some code that I got from another page. Is there any chance that you could adapt it?

    /* Redirect to Forum after Join Group. */

    function bpfr_custom_group_default_tab($default_tab){
    /**
    * class_exists() is recommanded to avoid problems during updates
    * or when Groups Component is deactivated
    */
    if ( class_exists( ‘BP_Group_Extension’ ) ) : //

    $group=groups_get_current_group();//get the current group

    if(empty($group))
    return $default_tab;

    switch($group->slug){

    case ‘social-group-547668396′: // group name (slug format)
    $default_tab=’calendar’;
    break;

    case ‘husbands-out’: // another group
    $default_tab=’forum’; // goes on a different tab
    break;

    // case etc, etc…

    default:
    $default_tab=’home’;// the default landing tab
    break;

    }

    return $default_tab;

    endif; // class end
    }

    add_filter(‘bp_groups_default_extension’,’bpfr_custom_group_default_tab’);
    Sat Jan 9 2016, 9:03:59 PM
    (0) Reply

    Add file

    danbp
    Moderator

    @leanneoleary,

    already solved many times on the forum. Choose from here ! 😉

    danbp
    Moderator

    Try this snippet, which let’s you determine wich tab you will see first when on a group.

    function bpfr_custom_group_default_tab($default_tab){
    	/**
    	 * class_exists() is recommanded to avoid problems during updates 
    	 * or when Groups Component is deactivated
    	 */
    	if ( class_exists( 'BP_Group_Extension' ) ) : // 
    	
    	$group=groups_get_current_group();//get the current group
    	
    	if(empty($group))
    	return $default_tab;
    	
    	switch($group->slug){
    		
    		case 'kill-bill': // group name (use slug format)
    		$default_tab='forum';
    		break;
    		
    		case 'titanic':
    		$default_tab='members';
    		break;
    		
    		default:		
    		$default_tab='home';// the original default landing tab
    		break;
    		
    	}
    	
    	return $default_tab;
    	
    	endif; // end if ( class_exists( 'BP_Group_Extension' ) )
    }
    add_filter('bp_groups_default_extension','bpfr_custom_group_default_tab');

    Comment shane’s function before using this function.

    Iryna_B
    Participant

    WP 3.92
    BP 2.1

    Hi, I’m trying to change the landing page for groups to redirect to Forums tab. I used this code, but it didn’t do a thing. I pasted it in functions.php of my child theme.

    
    function bpfr_custom_group_default_tab($default_tab){
    	/**
    	 * class_exists() is recommanded to avoid problems during updates 
    	 * or when Groups Component is deactivated
    	 */
    	if ( class_exists( 'BP_Group_Extension' ) ) : // 
    	
    	$group=groups_get_current_group();//get the current group
    	
    	if(empty($group))
    	return $default_tab;
    	
    	switch($group->slug){
    		
    		case 'XYZ': // group name (slug format)
    		$default_tab='forum';
    		break;
    		
    		case 'another-group': // another group 
    		$default_tab='members'; // goes on a different tab
    		break;
    		
                    // case etc, etc...
    
    		default:		
    		$default_tab='home';// the default landing tab
    		break;
    		
    	}
    	
    	return $default_tab;
    	
    	endif; // class end
    }
    add_filter('bp_groups_default_extension','bpfr_custom_group_default_tab');

    Any suggestions of why is it not working?

    #187260
    danbp
    Moderator

    @gabrieldespinoza,

    this button has two functions: Join group or Leave group and is ajax dependent. So you cannot modify it easily. See /bp-legacy/budypress-functions.php:1157 how it’s done.

    The best approach is to modify the landing page when you go on a group. By default, you go to the group home page.

    Add this to your child-theme functions.php

    
    function bpfr_custom_group_default_tab($default_tab){
    	/**
    	 * class_exists() is recommanded to avoid problems during updates 
    	 * or when Groups Component is deactivated
    	 */
    	if ( class_exists( 'BP_Group_Extension' ) ) : // 
    	
    	$group=groups_get_current_group();//get the current group
    	
    	if(empty($group))
    	return $default_tab;
    	
    	switch($group->slug){
    		
    		case 'XYZ': // group name (slug format)
    		$default_tab='forum';
    		break;
    		
    		case 'another-group': // another group 
    		$default_tab='members'; // goes on a different tab
    		break;
    		
                    // case etc, etc...
    
    		default:		
    		$default_tab='home';// the default landing tab
    		break;
    		
    	}
    	
    	return $default_tab;
    	
    	endif; // class end
    }
    add_filter('bp_groups_default_extension','bpfr_custom_group_default_tab');

    May this help ! 😉

    danbp
    Moderator

    @sbampfylde,

    in other words, you want to change the landing tab when visiting one of these groups.

    Each group screen as his own search filter. So if you are on the group forum screen, you see the forum activity filter. When you are on the group members screen, you see the group members search filter. And so on…

    So no matter about filtering, if you bring the visitors to the right screen as soon as they arrive on the group, they get the correct filter.

    FYI function is theme dependant and bp-custom is completely independant from bp updates and will work even if you change your theme.
    Here’s the code you can use (in functions.php or bp-custom.php)

    function bpfr_custom_group_default_tab($default_tab){
    	/**
    	 * class_exists() is recommanded to avoid problems during updates 
    	 * or when Groups Component is deactivated
    	 */
    	if ( class_exists( 'BP_Group_Extension' ) ) : // 
    	
    	$group=groups_get_current_group();//get the current group
    	
    	if(empty($group))
    	return $default_tab;
    	
    	switch($group->slug){
    		
    		case 'Public Events': // group name (slug format)
    		$default_tab='members';
    		break;
    		
    		case 'Private Investigations':
    		$default_tab='members';
    		break;
    		
    		case 'another group':
    		$default_tab='admin';
    		break;
    		
    		default:		
    		$default_tab='home';// the original default landing tab
    		break;
    		
    	}
    	
    	return $default_tab;
    	
    	endif; // end if ( class_exists( 'BP_Group_Extension' ) )
    }
    add_filter('bp_groups_default_extension','bpfr_custom_group_default_tab');

    Add or remove the “case” part into the switch to your needs. Don’t forget to modify the groups name to yours.

    danbp
    Moderator

    Hi @offthepage,

    Put this into bp-custom.php or in your child theme functions.php
    This is only an example ! Don’t forget to change group names and tabs name to your needs.
    Just add/remove a case into the switch for each group you want to modify.

    function bpfr_custom_group_default_tab($default_tab){
    	/**
    	 * class_exists() is recommanded to avoid problems during updates 
    	 * or when Groups Component is deactivated
    	 */
    	if ( class_exists( 'BP_Group_Extension' ) ) : // 
    	
    	$group=groups_get_current_group();//get the current group
    	
    	if(empty($group))
    	return $default_tab;
    	
    	switch($group->slug){
    		
    		case 'kill-bill': // group name (slug format)
    		$default_tab='forum';
    		break;
    		
    		case 'another-group':
    		$default_tab='members';
    		break;
    		
    		case 'group-test':
    		$default_tab='admin';
    		break;
    		
    		default:		
    		$default_tab='home';// the original default landing tab
    		break;
    		
    	}
    	
    	return $default_tab;
    	
    	endif; // end if ( class_exists( 'BP_Group_Extension' ) )
    }
    add_filter('bp_groups_default_extension','bpfr_custom_group_default_tab');
Viewing 9 results - 1 through 9 (of 9 total)
Skip to toolbar