Make BuddyPress Activity Pages Invisible to my Users

I know that the Activity Pages cannot be removed from BuddyPress but is there a way to make them invisible or to redirect to the forums instead of group pages.

Thank you.

  • Mary

    Hi Predrag,

    I need Activity Streams activated because when deactivated my links are reduced to Forum, Calendar, Send Invites.

    When activated I also get Members and Email Options - both of which I want to show.

    So I need Activity Streams activated, but I do not want Activity/Group pages to display.

    My members keep getting directed to the activity/groups page when they Join Group, and they post to that page. Then they wonder why their posts are not showing up on the Forums.

  • Mary

    Thank you Predrag. I have tried that code and it didn't work. I contacted BuddyPress and they said,

    "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."

    I told them that this was greek (geek) to me so they followed up with is

    "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)."

    So I have a redirect plugin. Can you tell me the urls that I need "in" and "out" please.

  • Adam Czajczyk

    Hello Mary!

    The "URL Redirect" plugin that you're using on your site will not work well in this case as it does not allow any type of "wild-card" URLs as input, meaning that you cannot specify an URL such as for example

    "yoursite.com/members-area/*/activity"

    (where "*" would constitute a replacement for username) as an "in" URL that would then be redirected.

    Therefore the plugin should either allow such URL's or be a "BuddyPress-dedicated" extension. That said, what do you think about this one?

    https://wordpress.org/plugins/buddypress-login-redirect/

    Although it does not allow you to set a "permanent" redirection (so users wouldn't be able to access activity pages at all), it does allow you to set your own URL as target URL and do redirect users upon login. You could then set the "target" url to your forum's URL and this should help members avoid confusion.

    Would that do the work for you?

    Best regards,
    Adam

  • Mary

    I just got this info from BP but I don't know enough to do anything with it.

    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.

  • Adam Czajczyk

    Hello Mary,

    I hope you're having a nice day!

    It seems that you got a ready to use code from their forum. What you will want to do to make use of it would be to add it to the "functions.php" file of your current theme.

    To do this, please follow these steps:
    - access your server via FTP
    - go to /wp-content/themes/THEME/ folder (where THEME is a name of you site's theme folder - similar to theme name)
    - edit functions.php file with a "clean text" editor (e.g. Notepad++, Sublime or similar)
    - paste that code at the end of the file
    - save file and test it

    In case it didn't work as expected, just remove it and everything will get back to current state. In such case we'll further investigate the issue.

    Best regards,
    Adam

  • Mary

    Thank you Adam. This seems to work.

    Is it possible to add some code that will do the same thing for "Leave Group"

    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 );

    Thank you!

  • Mary

    Thank you Predrag. I suspect this will work but I am having the same problem I had a while ago in that I can't "Leave Group" to test it. I keep getting a message "Are you sure you want to leave this group?" When I click OK it takes me back to the same page with "Leave Group" button available. It doesn't matter how many times I click that I want to leave group, it doesn't work.

    I don't think this is associated with the code you gave me but am keeping it in the same ticket just in case.

  • Mary

    It's hard to give you answers on this issue because no two things happen exactly the same each time I test it. I can join group and all works perfectly, with no activity page showing, but when I try to leave group I can't. I get asked if I really want to leave.

    I try logging out, dumping cache (wp rocket and browser) and do it again, and all works OK for leave group but then I can't join.

    It seems to be totally random when it works and when it doesn't. I try it with Safari, Firefox and Chrome, as Chat_Admin (Admin) and also as Mary (subscriber), and each time the result is different - i.e. occasionally everything works fine but most times it doesn't.

    It doesn't seem to matter if I include the code or not. I am unable to get it to work consistently.

  • Predrag Dubajic

    Hi Mary,

    I just tested this process on your site and everything worked for me without any issues, I was able to join and leave the group, after leaving I was redirected to christiangayschat.com/bpgroups//redirect-page/ double slash is probably because of the above code snippet, so you only need to remove first dash to work properly.

    Since this process sometimes works and sometimes doesn't I still suspect on caching issue.
    I would suggest doing more testing while WP Rocket and Wordfence cachings are disabled, also check that you don't have any server side caching.

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.