Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_after_has_activities_parse_args'

Viewing 23 results - 51 through 73 (of 73 total)
  • Author
    Search Results
  • Andrew
    Participant

    I’m filtering my activity pages using the bp_after_has_activities_parse_args filter and using conditionals depending on the activity page. But my conditionals are not working correctly for my custom pages. I’m not great with PHP but I’ve followed the instructions the best I can to put this together and I hope someone can help me with this to find a work around.

    Here is what I’ve done.

    I’m creating custom activity pages by setting them up in admin>pages>add page ‘custom-page-1’, ‘custom-page-2’ etc. I’ve setup each of these pages similar to the activity/index.php to create the activity loop:

    <div id="buddypress">
    
    	<div class="activity">
    			
    		<?php bp_get_template_part( 'activity/activity-loop' ); ?>
    				
    	</div>
    </div>

    Now with the parse_args filter, I can use conditionals to filter some of the activity pages, but my conditionals are not working correctly for my custom pages – they work to begin with but when I click the load more button, the new items are not being filtered. Here is an example to show you what is working and what is not (using the per_page filter for demonstration):

    function cm_activity_filter( $retval ) {
    
    	// The following conditionals to filter are working fine:
    
    	// Activity directory
    	if ( bp_is_activity_directory() ) {
    		$retval['per_page'] = 2;
        }
    	
    	// User profile just-me component
    	if ( bp_is_current_action( 'just-me' )) {
    		$retval['per_page'] = 3;
        }
    	 
    	 // A custom component in the members profile I setup using bp_core_new_nav_item
    	 if ( bp_is_current_action( 'custom-compenent' )) {
    		$retval['per_page'] = 10;
        }
    
    	
    	
    	// The following conditionals to filter my custom pages are not working when the load more button is clicked :
    	
    	// custom activity page 1
    	if (is_page( 'custom-page-1' ) ) {
    		$retval['per_page'] = 2;
    	}
    	
    	// custom activity page 2 
    	if (is_page( 'custom-page-2' ) ) {
    		$retval['per_page'] = 8;
        }
    	
    	
    	
        return $retval;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'cm_activity_filter' );

    So the is_page() conditionals are not working when the load more button is clicked. Is there a way to get this to work correctly. Any help appreciated.

    AM77
    Participant

    Thanks @r-a-y that does work for the front page, but bp_is_component_front_page( 'activity' ) or the one I just suggested bp_is_activity_front_page() doesn’t seem to work correctly when using the activity parse args filter. The best solution I’ve got now is using ! bp_is_user() && bp_is_current_component( 'activity' ) This makes this work correctly:

    /* Display just the activity updates for who the the logged-in 
    user is following and updates from the logged in user*/
    
    function am_activity_filter( $retval ) {
       
       if ( ! bp_is_user() && bp_is_current_component( 'activity' ) ) {  
    	   $retval['scope'] = 'following,just-me'; 
    	   $retval['action'] = 'activity_update';  
       }
       
       return $retval;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'am_activity_filter' );

    The problem with this conditional bp_is_component_front_page( 'activity' ) in my activity parse args filter is activity items keep showing from everyone instead of the items from who a user is following (I’m using your master follow plugin). The items that are not supposed to display, disappear when the user refreshes the page which makes the correct items display, but they keep coming back through the ‘load newest’. Have you tried this? Nevertheless ! bp_is_user() && bp_is_current_component( 'activity' ) is the one that is working correctly for this.

    #246126
    nicolemb
    Participant

    Thanks @shanebp – This is our problem. This whole solution hinges on adding meta with the blog id to EVERYTHING that could appear in an activity stream. (We also have Activity Plus Plugin active on one site and those posts seem to be missing getting the meta added)

    Is there something we hook to in order to add meta to all activity? we tried add_action('bp_activity', 'where_activity_from', 10, 3); but it’s still not adding meta to all.

    Or is there a better way to filter activity streams to only show activity from the current site on a multisite setup?

    Here’s our latest attempt at a must-use plugin, but not all activity is shown implying the meta values are not being added:

    <?php
    
    // Add Blog ID meta to activity posts
    add_action('bp_activity', 'where_activity_from', 10, 3);
    function where_activity_from($content, $user_id, $activity_id)
    {
        bp_activity_add_meta($activity_id, '_source_blog', get_current_blog_id());
    }
    
    // Filter specific sites for activity from that site only
    function bp_after_has_activities_parse_args_func($r)
    {
        $blog_id = get_current_blog_id();
        global $wpdb;
        $sql = $wpdb->prepare("SELECT activity_id FROM " . $wpdb->base_prefix . "bp_activity_meta WHERE meta_key=%s AND meta_value=%d", '_source_blog', $blog_id);
    
        $ids = array_values($wpdb->get_col($sql));
        if (empty($ids)) {
            $r['in'] = '-1';
        } else {
            $r['in'] = $ids;
        }
        return $r;
    }
    
    if (get_current_blog_id() !== 1) {
        add_filter('bp_after_has_activities_parse_args', 'bp_after_has_activities_parse_args_func');
    }
    #246103
    nicolemb
    Participant

    My site is completely up to date on WP and BP. I would like to filter activity loops on a multisite and have created a must use plugin to filter the activity to include only what is happening on the current site, with all activity shown on the main site. I have this but it is currently filtering too much, only showing very limited activity feeds, so it seems like I am over filtering my results. Any suggestions on how to get this right? Do I also have to filter member loops to achieve this completely?

    add_action('bp_activity_posted_update', 'where_activity_from', 10, 3);
    function where_activity_from($content, $user_id, $activity_id)
    {
    bp_activity_add_meta($activity_id, '_source_blog', get_current_blog_id());
    }

    function bp_after_has_activities_parse_args_func($r)
    {
    $blog_id = get_current_blog_id();
    global $wpdb;
    $sql = $wpdb->prepare("SELECT activity_id FROM " . $wpdb->base_prefix . "bp_activity_meta WHERE meta_key=%s AND meta_value=%d", '_source_blog', $blog_id);

    $ids = array_values($wpdb->get_col($sql));
    if (empty($ids)) {
    $r[‘in’] = ‘-1’;
    } else {
    $r['in'] = $ids;
    }
    return $r;
    }

    if (get_current_blog_id() !== 1) {
    add_filter('bp_after_has_activities_parse_args', 'bp_after_has_activities_parse_args_func');
    }

    #244998
    Vikram Shaw
    Participant

    Hi, I’m using latest version of buddypress. I want to customize my activity page to show updates on activity page for me and my friends only, so I’ve used the codes which was given by @R-A-Y. But I want to make the blogs updates to be shown in activity page to everyone irrespective of friend, but I don’t know how to achieved that because the code which I’ve used is restricting to me and my friends only. And even I want to give “News” update in activity page can anyone suggest me how to achieve that two things.

    The codes which I’ve used for activity page which shows activity updates for me and my friends is given below:–

    add_action( 'bp_loaded', array( 'BP_Home', 'init' ) );
    /**
     * BP Home
     */
    class BP_Home {
    	/**
    	 * Our activity scope name.
    	 *
    	 * @var string
    	 */
    	const SCOPE_NAME = 'swa-home';
    	/**
    	 * Multiple scopes we will be using for our 'Home' tab.
    	 *
    	 * @var string
    	 */
    	protected static $scopes = '';
    	/**
    	 * Marker to determine when to stop our object buffer
    	 *
    	 * @var bool
    	 */
    	public $should_end_buffer = false;
    	/**
    	 * Static initializer.
    	 */
    	public static function init() {
    		return new self();
    	}
    	/**
    	 * Constructor.
    	 */
    	public function __construct() {
    		if ( ! bp_is_active( 'activity' ) ) {
    			return;
    		}
    		// set our default scopes
    		$this->set_default_scopes();
    		// add in our hooks
    		$this->hooks();
    	}
    	/**
    	 * Sets the default scopes used by the "Home" tab.
    	 *
    	 * Filterable.
    	 */
    	private function set_default_scopes() {
    		$scopes = array();
    		$scopes[] = 'just-me';
    		$scopes[] = 'mentions';
    		if ( bp_is_active( 'friends' ) ) {
    			$scopes[] = 'friends';
    		}
    		self::$scopes = apply_filters( 'bp_activity_home_scopes', $scopes );
    	}
    	/**
    	 * Hooks.
    	 */
    	private function hooks() {
    		add_action( 'bp_activity_screen_index', array( $this, 'set_home_scope' ) );
    		add_action( 'wp_logout',                array( $this, 'reset_activity_scope_cookie' ) );
    		add_filter( 'bp_after_has_activities_parse_args', array( $this, 'filter_activity_loop' ) );
    		add_action( 'bp_before_activity_type_tab_all',       array( $this, 'ob_start' ), 0 );
    		add_action( 'bp_before_activity_type_tab_friends',   array( $this, 'ob_end_clean' ), 0 );
    		add_action( 'bp_before_activity_type_tab_groups',    array( $this, 'ob_end_clean' ), 0 );
    		add_action( 'bp_before_activity_type_tab_favorites', array( $this, 'ob_end_clean' ), 0 );
    	}
    	/**
    	 * Override some activity default / AJAX parameters if we're on the Sitewide Activity page.
    	 */
    	public function set_home_scope() {
    		// reset cookie for logged-out users
    		if ( ! is_user_logged_in() ) {
    			$this->reset_activity_scope_cookie();
    			return;
    		}
    		// override post title
    		add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'post_title' ), 20 );
    		// if we have a post value already, let's add our scope to the existing cookie value
    		if ( !empty( $_POST['cookie'] ) ) {
    			$_POST['cookie'] .= '%3B%20bp-activity-scope%3D' . self::SCOPE_NAME;
    		} else {
    			$_POST['cookie'] = 'bp-activity-scope%3D' . self::SCOPE_NAME;
    		}
    		// set the activity scope by faking an ajax request (loophole!)
    		if ( ! defined( 'DOING_AJAX' ) ) {
    			$_POST['cookie'] .= "%3B%20bp-activity-filter%3D-1";
    			// reset the selected tab
    			@setcookie( 'bp-activity-scope',  self::SCOPE_NAME, 0, '/' );
    			//reset the dropdown menu to 'Everything'
    			@setcookie( 'bp-activity-filter', '-1',   0, '/' );
    		}
    	}
    	/**
    	 * Resets BP's activity scope cookie to 'all'.
    	 *
    	 * Only reset if the activity scope is set to 'swa-home' since the 'Home' tab
    	 * will not be available when logged out.
    	 *
    	 * We do this when a user is logging out or is logged out.
    	 */
    	public function reset_activity_scope_cookie() {
    		if ( ! empty( $_COOKIE['bp-activity-scope'] ) && self::SCOPE_NAME === $_COOKIE['bp-activity-scope'] ) {
    			@setcookie( 'bp-activity-scope', 'all', 0, '/' );
    			$_COOKIE['bp-activity-scope'] = 'all';
    		}
    	}
    	/**
    	 * Filter the activity loop with our custom scope.
    	 */
    	public function filter_activity_loop( $r ) {
    		if ( self::SCOPE_NAME !== $r['scope'] ) {
    			return $r;
    		}
    		// add in our custom scopes
    		$r['scope'] = self::$scopes;
    		// change default empty activity text as well while we're at it
    		add_filter( 'gettext', array( $this, 'override_empty_message' ), 10, 3 );
    		return $r;
    	}
    	/**
    	 * Start the object buffer before any activity tabs are outputted.
    	 */
    	public function ob_start() {
    		if ( ! is_user_logged_in() ) {
    			return;
    		}
    		ob_start();
    	}
    	/**
    	 * Replace the "All Members" tab with "Home" on the Sitewide Activity page.
    	 *
    	 * Try to determine when to stop our object buffer and inject our "Home" tab.
    	 * Accounts for whether certain BP components are active or not.
    	 */
    	public function ob_end_clean() {
    		if ( ! is_user_logged_in() ) {
    			return;
    		}
    		if ( false === $this->should_end_buffer ) {
    			$this->should_end_buffer = true;
    			$buffer = ob_get_contents();
    			ob_end_clean();
    			// find the default 'All Members' tab
    			$all_start = strpos( $buffer, '<li class="selected" id="activity-all">' );
    			$all_end   = strpos( $buffer, '</li>', $all_start );
    			// our custom 'Home 'tab
    			$home = '<li class="selected" id="activity-' . self::SCOPE_NAME . '"><a href="' . bp_get_activity_directory_permalink() . '">' . __( "Home", "bp-home" ) . '</a></li>';
    			// output and replace the 'All Members' tab with the 'Home' tab
    			echo substr_replace( $buffer, $home, $all_start, $all_end + 5 );
    		}
    	}
    	/**
    	 * Post title override.
    	 *
    	 * Whee! Dirty hack!
    	 */
    	public function post_title() {
    		global $wp_query;
    		$wp_query->post->post_title = __( 'Home', 'bp-home' );
    	}
    	/**
    	 * Overrides the "Sorry, there was no activity found. Please try a different filter." message.
    	 *
    	 * @param string $translated Current translated text
    	 * @param string $untranslated Untranslated text
    	 * @param string $domain Domain for the string
    	 * @return string
    	 */
    	public function override_empty_message( $translated, $untranslated, $domain ) {
    		if ( 'Sorry, there was no activity found. Please try a different filter.' === $untranslated ) {
    			$translated = sprintf( __( "It looks like you're new here. To see some activity, try posting an update or <a href='%s'>adding a friend</a>.", 'bp-home' ), bp_get_members_directory_permalink() );
    		}
    		return $translated;
    	}
    }
    #244072
    djsteveb
    Participant

    For the first time, I think ever, I tried clicking the dropdown to select different activity to show on the site-wide activity page. Tried some of the selections, but they all just made the original everything on the page show (after an ajaxy looking refresh)

    So I wonder if using the parse_Args code to modify the default activity stream things that display is overriding this drop down menu function?

    If so, we need a better way to hide things from the activity stream in the future.

    And I guess we need a way to remove the dropdown menu from showing since it does not work.

    If this parse args code is not affecting the dropdown selection then I guess I have to start deactivating other plugins to see if they are screwing with it.

    my current bp-custom file:

    <?php
    // hacks and mods will go here
    define( 'BP_DEFAULT_COMPONENT', 'profile' );
    function remove_xprofile_links() {
        remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );
    }
    add_action( 'bp_init', 'remove_xprofile_links' );
    // block activity stream stuff - things to include
    function my_bp_activity_types( $retval ) {
    	// existing BP/bbP activities
    	// remove the one you wont to see from that list
    	$retval['action'] = array( 
    		'activity_comment',
    		'activity_update',
    		'bbp_topic_create',
    		'last_activity',
    		'new_blog_post', 	
    		'new_member',
    		'updated_profile',
    		'rtmedia_update',
    		'bp_doc_created',
    		'new_groupblog_post',
    		'bp_album_picture',
    		'added_group_document',
    		'new_blog_comment',
    		'new_member',
    		'created_group'
    	);	
    
    	return $retval;
    	
    	}
    add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activity_types' );
    // block activyt stream stuff removed friendship_created, new_avatar,bp_doc_edited,activity_liked,
    // deleted_group_document, new_blog, new_forum_post, new_forum_topic, new_status,new_wire_post, joined_group, new_avatar,
    // previously blocked via plugin - deleted_group_document, new_blog, new_member, joined_group, friendship_created, activity_liked
    ?>
    #244036

    In reply to: filter activity loop

    Angelo Rocha
    Participant

    Works fine with a little change:

    function omni_filter_activity( $retval ) {
        $retval['action'] = 'bbp_reply_create,bbp_topic_create'; // change scope per action
        return $retval;
    } add_filter( 'bp_after_has_activities_parse_args', 'omni_filter_activity' );
    #243867

    In reply to: filter activity loop

    shanebp
    Moderator

    Try:

    function angelo_filter_activity( $retval ) {
        
        $retval['scope'] = 'bbp_reply_create,bbp_topic_create';
     
        return $retval;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'angelo_filter_activity' );
    #242974
    danbp
    Moderator

    @djsteveb,

    i wouldn’t remove the whole action hook, as other functionnalities from other plugins, can use it. Filtering is even better.

    bp_parse_{component}_args is intended to filter template loops.

    If you remove an {activity} type with this function, it will remove that activity from each activity feed (swa, profile and group). Something like an all or nothing thing.

    bp_parse return values. So if you want to remove something, you have to list what you want to keep to show, and not what to remove !

    Here a snippet, listing all existing BP activity types (2.2.x). Simply comment or remove the type you don’t want.

    function my_bp_activity_types( $retval ) {
    // list of all BP activity types  - remove or comment those you won't show.
        $retval['action'] = array(        
            'activity_comment',
    		'activity_update',
    		'created_group',
    		'friendship_created',
    		'joined_group',
    		'last_activity',
    		'new_avatar',
    		'new_blog_comment',
                    'new_blog_post',
    		'new_member',
    		'updated_profile'        
        );
     
        return $retval;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activity_types' );

    IMPORTANT: copy/paste to bp-custom.php or child-theme functions.php. Used as-is will do nothing ! You have to remove the type you don’t want from the list….

    Third party plugins (like bbPress) use also activity types. Easiest way to get the right type name is to check xxxx_bp_activity table in DB and search for it in the Type column.


    @umar007
    , removing friendship_created will solve your question.

    @djsteveb
    , remove new_avatar ! 😉

    djsteveb
    Participant

    I tried added a slightly modded version of the parse_Args thing @danbp posted here:

    https://buddypress.org/support/topic/how-to-hide-forum-topics-and-replies-but-now-mentions-in-activity-feed/#post-242486

    to thin out the activity stream.. and now the widget I have in sidebar that was showing sitewide posts from member blogs is showing stuff that is in the activity stream like “member x joind group b”

    Is this something that is supposed to happen, a side effect of using the parse args mucking with the site tracking that the recent posts widgets gets / pulls from?

    Maybe I messed up the code to filter the activity stream and this is my created bug – or maybe doing things this way does indeed affect the other?

    my bp-custom.php:

    
    <?php
    // hacks and mods will go here
    define( 'BP_DEFAULT_COMPONENT', 'profile' );
    function remove_xprofile_links() {
        remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );
    }
    add_action( 'bp_init', 'remove_xprofile_links' );
    // block activity stream stuff - things to include
    function demo_parse( $retval ) {
    	// existing BP/bbP activities
    	// remove the one you wont to see from that list
    	$retval['action'] = '
    		activity_comment,
    		activity_update,
    		bbp_topic_create,
    		joined_group,
    		last_activity,
    		new_avatar,
    		new_blog_post, 	
    		new_member,
    		updated_profile,
    		rtmedia_update,
    		bp_doc_created,
    		new_groupblog_post,
    		bp_album_picture,
    		added_group_document,
    		new_blog_comment,
    		new_member,
    		created_group,
    	';	
    
    	return $retval;
    	
    	}
    add_filter( 'bp_after_has_activities_parse_args', 'demo_parse' );
    // block activity stream stuff removed friendship_created, new_avatar,bp_doc_edited,activity_liked,
    // deleted_group_document, new_blog, new_forum_post, new_forum_topic, new_status,new_wire_post
    // previously blocked via plugin - deleted_group_document, new_blog, new_member, joined_group, friendship_created, activity_liked
    ?>
    danbp
    Moderator

    @tomnikkola,

    as you discovered already, the CSS trick is a poor solution.
    Two solution are on hand.
    A first one, which applies to all activity feeds.
    Basically the below snippet handles globally the activties output. You simply remove the activity(ies) you don’t want to see from the list. Note that almost all activity types are listed.
    Add it to child functions.php or to bp-custom.php

    function demo_parse( $retval ) {
    	// existing BP/bbP activities
    	// remove the one you wont to see from that list
    	$retval['action'] = '
    		activity_comment,
    		activity_update,
    		bbp_topic_create,
                    bbp_reply_create,
    		friendship_created,
    		joined_group,
    		last_activity,
    		new_avatar,
    		new_blog_post, 	
    		new_member,
    		updated_profile
    	';	
    
    	return $retval;
    	
    	}
    add_filter( 'bp_after_has_activities_parse_args', 'demo_parse' );

    Codex:

    Using bp_parse_args() to filter BuddyPress template loops

    The second solution, is to use a child-theme with a modified activity loop. This let you handle finer condition for each user.

    Read this tut how you can do that.

    Codex:

    Activity Loop

    puffyjoe
    Participant

    I’ve added a CITY profile field to user.

    I now want to filter the global activities feed by this. So I need to save the users’ city value when they create an update.

    So far, I can filter by content, grab the city from the user, and filter by that city and if the text is in the content it works.

    But it would be nicer to be able to use a meta param on the update, set that to city, and filter by that. I just cant find the documentation.

    right now this is what I am doing:

    function my_filter_activity( $loop ) {
        $user_id = bp_loggedin_user_id();
        $city = xprofile_get_field_data('9', $user_id);
        $loop['search_terms'] =  $city ;
        return $loop;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'my_filter_activity' );

    The main help I need is … how can I store the users city. I guess it’s ok if it shows as a header on their update like:
    ” City: Orlando
    <update text>

    but better as a meta searchable attribute.

    Then eventually (Part 2) I’d like to have a dropdown where the user can override their registered city and the value of the dropdown in the update would be saved instead.

    Help! Thanks!

    r-a-y
    Keymaster

    The simple thing here is to remove all your custom code snippets that are interacting with the activity stream.

    In your original post, I see you’re using this:
    remove_filter( 'bp_after_has_activities_parse_args', 'ray_bp_display_comments_stream', 20 );

    Which means you have a function called ray_bp_display_comments_stream() somewhere which is causing the singular activity comment entries to display.

    danbp
    Moderator

    @browserco,

    thank you for your help, but please, don’t give a 4 years old solution without testing it.
    At first, the snippet contains cote errors, and second, it doesn’t work with BP 2.x, as things has changed.

    You can easily modify your template loop by using bp_parse_args function.

    Here a working example (activity-update is commented – uncomment to see the difference)

    You simply have to list what to show. Anything not listed will be ignored, on all activity feeds.

    Add this to bp-custom.php or child theme functions.php

    function my_bp_activities_include_activity_types( $retval ) {
    // only allow the following activity types to be shown
        $retval['action'] = array(
         //   'activity_update',
            'activity_comment',
            'new_blog_post',
            'new_blog_comment',
            'friendship_created',
            'created_group',
        );
     
        return $retval;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activities_include_activity_types' );
    #237964

    In reply to: activity

    danbp
    Moderator

    Hi,

    to show only notices (aka updates) on the SWA, try this snippet (place in bp-custom.php)

    function make_swa_show_notice_only( $retval ) {	
    	
    	if ( bp_is_page( 'activity' ) ) {
    	$retval['action'] = 'activity_update';					
    	}
    	
    	return $retval;
    	
    	}
    add_filter( 'bp_after_has_activities_parse_args', 'make_swa_show_notice_only' );

    Reference: https://codex.buddypress.org/developer/using-bp_parse_args-to-filter-buddypress-template-loops/

    browserco
    Participant

    Hi everyone, I would like to remove the function that forces activity comments to show as separate entries. It is filling up my activity stream and overshadowing my activity posts. Commenting on another user’s activity post is the core feature of my network, but I think comments should stay where they are posted. I have unchecked the options in BuddyPress settings page to not allow comments from blog post and forum. Also it is not good for privacy as anyone can see all of another user’s comments and replies on their activity feed while viewing that user’s profile. I am using the BP Activity Privacy plugin but it has no affect on comments and replies.

    I am not good with coding but have come up with this code to attempt to remove it:
    // Stop activity loops from showing activity comments as separate entries

    function remove_comment_replies() {
    remove_filter( ‘bp_after_has_activities_parse_args’, ‘ray_bp_display_comments_stream’, 20 );

    add_action( ‘bp_after_has_activities_parse_args’, ‘remove_comment_replies’ );

    It doesn’t work. Any suggestions would be very much appreciated (see link to better understand what I am referring to.) Thank you.

    #236020
    danbp
    Moderator

    Recently introduced function bp_parse_args allows since 2.0 to modify easely your templates. Faster and lighter than a plugin.

    Using bp_parse_args() to filter BuddyPress template loops

    As example, show only updates on the SWA (add snippet to bp-custom.php or child-theme functions.php)

    function make_swa_show_notice_only( $retval ) {	
    	
    	if ( bp_is_page( 'activity' ) ) {
    	$retval['action'] = 'activity_update';					
    	}
    	
    	return $retval;
    	
    	}
    add_filter( 'bp_after_has_activities_parse_args', 'make_swa_show_notice_only' );
    danbp
    Moderator

    Try this to remove ALL activity feeds

    function bpfr_hide_rss_feeds() {	
       remove_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
       remove_action( 'bp_actions', 'bp_activity_action_personal_feed' );
       remove_action( 'bp_actions', 'bp_activity_action_friends_feed' );
       remove_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
       remove_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
       remove_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
       remove_action( 'groups_action_group_feed', 'groups_action_group_feed' );    
    }
    add_action('init', 'bpfr_hide_rss_feeds');

    This snippet will only show logged in users friends activities (on all activity pages of the site)

    
    function bpfr_filtering_activity( $retval ) {
    	$retval['scope'] = 'friends';		
    		return $retval;
    	}
    add_filter( 'bp_after_has_activities_parse_args', 'bpfr_filtering_activity' );

    Add to bp-custom.php or child-theme functions.php

    More details about this on Codex

    #234680
    deshmukh
    Participant

    @danbp thanks! For the first time, I could read the Codex, understand it and do something meaningful!

    In my functions.php, I added the following code:

    function myown_bp_activity( $retval ) { 
        $retval['scope'] = 'friends';                                                                                          
        return $retval;
      }
    
      add_filter('bp_after_has_activities_parse_args', 'myown_bp_activity' );
    

    This makes no difference at all. I guess, default for scope is friends. If I change ‘friends’ to ‘groups’, ALL activities show only group updates.

    The area where I am groping in the dark still is:

    • How do I modify ONLY the SWA? What should be the conditional? if (bp_is_SWA)?
    • Secondly, I can get ONLY groups. But I can not still get ONLY status updates. How do I get that? What should be the scope?

    Alright, I have an update.

    It turns out that BuddyPress Activity Plus was not to blame after all. For some reason, when I use $retval['object'] = 'status'; it only shows activity updates that I’ve just submitted. Once I refresh the page, the stream is empty again.

    So I changed the function you provided to try to get around this, and to be conditional to the home page of my eX-Stream site only:

    		function bpfr_filtering_activity( $retval ) {
    			global $blog_id;
    			
    			// activities to filter on, comma separated
    			if ( $blog_id == 13 && is_front_page() ) {
    				$retval['action'] = 'activity_update';
    			}
    			
    			return $retval;
    			}	
    		add_filter( 'bp_after_has_activities_parse_args', 'bpfr_filtering_activity' );
    rainerkormann
    Participant

    Hi @danbp

    I used your Code and it works like a charm – thanks a million 🙂

    One thing: using your nice Filter-Function, it’s only possible to make a comment, after one click on one, no matter which, of the Activity-Tabs (“All Members|Friends|Groups”)…

    Without that click, the “Comment”-Button of someones entry just doesn’t work 🙁

    PS: when I change the If-Statement to use your Code also for Groups, so only Updates are shown (which works), there is no way I can make the Comment-Button work…:

    function make_swa_show_notice_only( $retval ) {	
    	
    	 if ( bp_is_page( 'activity' ) || bp_is_page( 'groups' ) ) {
    		$retval['action'] = 'activity_update';					
    	 }
    	
    	return $retval;
    	
    }
    add_filter( 'bp_after_has_activities_parse_args', 'make_swa_show_notice_only' );

    Do you have an idea, what i can do?

    Thanks in advance,
    Rainer.

    dugfunny
    Participant

    How can i do it?

    I still want groups to be able to have their own, separate activity streams, but i want that information kept inside of their group, or if someone presses the “My Groups” tab at the top of the main activity page it should show up.

    Otherwise I don’t want group updates showing up on the main activity “wall”.

    Here is code I am using so far concerning what I want to show on the activity wall…

    /**
     * Activity Stream Default Updates
     */
    function make_swa_show_notice_only( $retval ) {	
    	
    	 if ( bp_is_page( 'activity' ) ) {
    		$retval['action'] = 'activity_update, rtmedia_update, forums_update, bbp_topic_create, bbp_reply_create';					
    	 }
    	
    	return $retval;
    	
    }
    add_filter( 'bp_after_has_activities_parse_args', 'make_swa_show_notice_only' );

    This basically makes only status updates, rtmedia updates(photos and such), and forum updates show up on my activity “Wall”. How can i tweak this code to NOT allow group updates to come through?

    Thanks!

    danbp
    Moderator

    Please don’t post BP files, it’s really unnecessary. We’re all BP user ! 👿
    Sorry, i didn’t correctly understand your request. I thought you wanted to change the order of the selectbox filters. If you also interested, see this old tread.

    SWA shows by default all site activities and they can be filtered. It is well documented on the Codex.

    If for some reason you don’t want to modify a theme file, you can use a custom function and put it into bp-custom.php

    Example ( BP 2.0+ only)

    function make_swa_show_notice_only( $retval ) {	
    	
    	 if ( bp_is_page( 'activity' ) ) {
    		$retval['action'] = 'activity_update';					
    	 }
    	
    	return $retval;
    	
    }
    add_filter( 'bp_after_has_activities_parse_args', 'make_swa_show_notice_only' );

    Now the swa shows only notices (if exist). If you need to see a member activity, you have to go on his profile. Same for groups, the activity is only on the group page.

Viewing 23 results - 51 through 73 (of 73 total)
Skip to toolbar