When Joining A Group I Want Default Page To Be Forum

When someone joins a group they are taken to the "Group" page. I want them to be taken to the "Forum" page.

How do I do this please.

  • Milan

    Hello @Mary,

    I hope you are having a good day and thanks for the asking. :slight_smile:

    Join/Leave group: button has two functions:
    #1) Join group or
    #2) Leave group and both are ajax dependent. So you cannot modify it easily.

    However you can change default landing page when you visit group with this little hack,

    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;
    
    		var_dump( $default_tab );
    
    		switch($group->slug){
    
    			case 'lovely-people': // group name (slug format)
    				$default_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');

    Just replace case value with your buddypress group slug text. When you view group you'll see full url in browser's address bar, in which at the very end you'll see group slug. In my case I've used "lovely-people" group slug which you would like to change to your group slugs.

    You can paste above code to your active functions.php file or child theme's functions.php file or better use this plugin https://wordpress.org/plugins/code-snippets/

    Code is taken and modified from https://buddypress.org/support/topic/redirect-after-join-group/

    Thanks!
    Milan.

  • Mary

    Thank you Milan. I tried using the Code Snippets plugin and got a fatal error so tried putting it in my functions.php of my child theme. I got the following:

    Fatal error: Cannot redeclare bpfr_custom_group_default_tab() (previously declared in /home/chat/public_html/chat-content/themes/generatepress_child/functions.php:145) in /home/chat/public_html/chat-content/themes/generatepress_child/functions.php on line 254

    I had changed lovely-people to lgbt (slug for Discussions about being LGBT)

    Not sure what I missed.

  • Milan

    Hello @Mary,

    I hope you are having a good day and sorry for being late here.

    It seems to me that in past you had pasted same code snippet to functions.php file of your child theme. Could you please remove previous snippet and try this new one, most probably you'll get previous snippet in functions.php file on line no 145.

    Please remove previous one and give a try this new one with modifications I've suggested you. :slight_smile:

    Cheers,
    Milan Savaliya.

  • Milan

    Hello @Mary,

    I hope you are having a good day.

    Dear member code I've give working fine on my sandbox site but surprisingly not working on your site, there must be something wrong going on your end. Would you mind if debug further with your ftp credentials ? Here please note that during debugging process I may have to deactivate other plugins and themes to evaluate my testing further. If you are okay with that please send me your ftp credentials via our secure private form https://premium.wpmudev.org/contact/

    Select "I have a different question" for your topic - this and the subject line ensure that it gets assigned to me :slight_smile:

    Send in:

    Subject: "Attn: Milan Savaliya"
    -WordPress admin username
    -WordPress admin password
    -login url
    -FTP credentials (host/username/password)
    -link back to this thread for reference
    -any other relevant urls

    Once we have this information then I can debug the issue further :slight_smile:

    Look forward to hearing back!

    Cheers,
    Milan Savaliya.

  • Milan

    Hello @Mary,

    I hope you are having a good day and thanks for sending me requested information.

    I've take a look at your site and go to know that actually you can't alter group joining and leaving behavior with above code for forum tab as its generated by bbpress plugin which is completely different plugin territory.

    Above code will work fine if you want to redirect user to one of the provided tab of buddypress for each groups( like home, members etc ) but can't work with bbpress generated tab for groups. Having that said you can't make default landing tab as forum when user join buddypress group. But that doesn't mean its not possible. It may be possible with lot of custom coding and for that i suggest you consider posting this as job on our job portal here,
    https://premium.wpmudev.org/jobs/new-job/

    I hope this helps you.

    Please let me know if there is anything else I can help you with.

    Cheers,
    Milan Savaliya

  • Mary

    Milan, I am so close to getting this using the following code in functions.php of child theme except that when I "Join Group" I get a message saying "Are you sure you want to do that? Try again."

    /* 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');

  • Milan

    Hello @Mary,

    I hope you are having a good day and really sorry for being late here.

    To test you mentioned issue I created test user and assign him one of your membership manually. Then I've created one dummy test group( sorry for using "test" word many times ) and try to join dummy user to one of created dummy group. Process went fine and member joined group without facing any issue. Have you resolved this issue or its still there ? if its still there then will you please provide me some more info ( or steps ) troughs which I can replicate issue ?

    Kind Regards,
    Milan Savaliya.

  • Milan

    Hello @Mary,

    Hope you are doing well.

    I didn't lost my track dear member. Sorry that it seems like that to you. Let me explain what was my purpose and intention of my last reply.

    Milan, I am so close to getting this using the following code in functions.php of child theme except that when I "Join Group" I get a message saying "Are you sure you want to do that? Try again."

    This was the question you asked me. And I tried to replicate this issue as you said its just causing some problem. So whole intention was answer is to confirm that is not happening the way you mentioned.

    But anyway forget about that all and lets focus on main question. :slight_smile:

    Dear member as I said you before, solution I've provided you only works with Buddypress default generated tabs( like home, members etc ) but can't work with bbpress generated tab for groups. Having that said you can't make default landing tab as forum when user join buddypress group. But that doesn't mean its not possible. It may be possible with some custom coding and for that i suggest you consider posting this as job on our job portal here,
    https://premium.wpmudev.org/jobs/new-job/

    I am sorry but there isn't anything else I can do with this. May be Buddypress community can help you. This isn't possible with simple snippet because Buddypress and Bbpress integration is kind of complex process to takel and alter their default flow.

    Kind Regards,
    Milan Savaliya.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.