Skip to:
Content
Pages
Categories
Search
Top
Bottom

stop public groups posting to the activity stream?

  • Avatar of mcpeanut
    mcpeanut
    Participant

    @mcpeanut

    hi, i have a strange request for help, let me explain why,

    ok the problem im facing is this i have managed to stop everything from showing in the activity stream completely to anyone who isnt a friend appart from the creation of public groups or comments in them “they can still be seen by everyone which spoils the whole concept of creating a friends only activity stream”. (i need to keep public groups as well as private, let me explain more)

    i cannot use the buddypress activity privacy to do this because i have also set up custom post types to show in the activity stream and when i use buddypress activity privacy to set the privacy in groups it also takes effect on my custom post types. so this is not in any way a valid option for me as good as the plugin is! (unless anyone has a suggestion on how to stop my custom post types from using the groups settings of this plugin?)

    so all i need to do if anyone has an answer for me is to exclude creation of public groups and comments posted in them from displaying in the activity stream. i must stress that i need to keep public groups and cannot just keep private groups creation instead.

    can anyone help me out with some code to do this?

    would be appreciated very mucho! :)

Viewing 6 replies - 1 through 6 (of 6 total)
  • Avatar of mcpeanut
    mcpeanut
    Participant

    @mcpeanut

    im looking through the bp-groups-activity.php am i in the right area?

    Avatar of mcpeanut
    mcpeanut
    Participant

    @mcpeanut

    found this section in the bp-groups-activity.php
    this seems to relate to the public groups, does anyone have any ideas on what to change here?

    // Set the default for hide_sitewide by checking the status of the group
    $hide_sitewide = false;
    if ( !empty( $args['item_id'] ) ) {
    if ( bp_get_current_group_id() == $args['item_id'] ) {
    $group = groups_get_current_group();
    } else {
    $group = groups_get_group( array( ‘group_id’ => $args['item_id'] ) );
    }

    if ( isset( $group->status ) && ‘public’ != $group->status ) {
    $hide_sitewide = true;
    }
    }

    $r = wp_parse_args( $args, array(
    ‘id’ => false,
    ‘user_id’ => bp_loggedin_user_id(),
    ‘action’ => ”,
    ‘content’ => ”,
    ‘primary_link’ => ”,
    ‘component’ => buddypress()->groups->id,
    ‘type’ => false,
    ‘item_id’ => false,
    ‘secondary_item_id’ => false,
    ‘recorded_time’ => bp_core_current_time(),
    ‘hide_sitewide’ => $hide_sitewide
    ) );

    return bp_activity_add( $r );
    }

    i have tried changing the $hide_sitewide = false; to $hide_sitewide = true;
    but this doesnt work properly.

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    > exclude creation of public groups and comments posted in them from displaying in the activity stream.

    Changing to $hide_sitewide will prevent it from appearing anywhere ( including the group activity stream ) except the activity stream for the person who created the item.

    You probably want items to appear in the group stream, so try this in bp-custom.php or your theme functions.php

    function remove_groups_from_activity( $activity ) { 
      if( $activity->component == 'groups' )
        $activity->hide_sitewide = true; 
    }
    add_action( 'bp_activity_before_save', 'remove_groups_from_activity', 1, 1); 

    Of course, this will only apply to new activity items.

    Then you need to ‘reveal’ those hidden items in a group stream…

    Create a template overload of this file:
    \bp-templates\bp-legacy\buddypress\activity\activity-loop.php

    Then before the loop, check if you’re viewing a group and if so, then change the
    bp_has_activities call to:

    if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . '&show_hidden=true') ) :

    The activity stream is quite flexible:

    http://codex.buddypress.org/developer/loops-reference/the-activity-stream-loop/

    Avatar of mcpeanut
    mcpeanut
    Participant

    @mcpeanut

    Hey @shanebp ty for your response, i have just woke up and read this and will be trying it in the next hour, i will update you on if this solved my problem or not.

    Create a template overload of this file:
    \bp-templates\bp-legacy\buddypress\activity\activity-loop.php

    i assume by this you mean copy this file over to my child twenty twelve theme and make the edits specified in there?

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    Avatar of mcpeanut
    mcpeanut
    Participant

    @mcpeanut

    @shanebp ty again shane, i still have not had the chance to try this, but im defo gonna get round to it in the next hour lol, so from reading that article i would make a buddypress folder in my twenty twelve child theme then add an activity folder inside it, then i should copy the activity-loop.php from the directory you specified. and then i would perform the edit you mentioned above? is this correct? just making sure im clear on what to do before doing it.

    or should i just copy the entire buddypress directory over from \bp-templates\bp-legacy\buddypress\ to my child theme before making the edit?

    i havent needed to do anything as of yet with buddypress template files you see as all other edits i have made have been in the functions.php and bp-custom.php

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.