Still hoping for a response on this one.
Thank you.
I would sure appreciate some help with this issue. I am very close to having it work using the functions.php code from the previous post. I am now getting the message, Are you sure you want to do that?
Can anyone give me some input on this please.
The idea here would be to hook in to an action that fires after the join group event. Check out add_action()
which should help you do that. You’d use bp_core_redirect()
inside your custom function.
Hoping this helps?
Ref https://codex.wordpress.org/Function_Reference/add_action
Thank you so much for trying to help but it’s all greek (or should I say geek) to me.
I wouldn’t have a clue where to start.
Thank you anyway.
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
Regarding your original question:
Is there a way to redirect to forum from “Join Group” button please.
The code you’ve posted here won’t perform a redirect; instead, it filters the default groups tab. I would imagine you’d also need a redirect put in place (which might explain why you see no change when you add the code snippet).
Thank you. Could you please be more explicit.
Do I need the above code PLUS redirect plugin or should I be able to do it with just plugin?
Can you give me an idea of the URL “in” to accomplish this please.
The URL “out” will be https://christiangayschat.com/bpgroups/social-group-547668396/forum/
But I can’t figure out what the “in” URL would be for Join Group and Leave Group.
The code you’ve posted gets the current group and first compares that group’s slug to social-group-547668396. If a match occurs, the default tab is set to calendar. If no match occurs then the group’s slug is compared to husbands-out. If a match occurs, the default tab is set to forum. If the group’s slug doesn’t match any of those, the default tab is set to home.
I don’t think any of this will happen at the point a join group button is clicked.
My thinking is you will need to hook to an action such as groups_join_group
(which will fire immediately after a user joins a group) and then perform a direct to the forum tab (or to the default tab if that is set to forum).
I think something like this:
function my_redirect_after_join_group( $group_id, $user_id ) {
$group = groups_get_group( array( 'group_id' => $group_id ) );
bp_core_redirect( bp_get_groups_directory_permalink() . $group->slug . '/forum/' );
}
add_action( 'groups_join_group', 'my_redirect_after_join_group', 10, 2 );
Please note I haven’t tested.
Thank you so much for trying to help Henry. I’m afraid I just don’t know enough about it to make this work.
Much appreciated!
I think we can close this ticket as it is just beyond my level of understanding.
Thank you again!