Skip to:
Content
Pages
Categories
Search
Top
Bottom

I've Figured Out How To Create a Facebook-Style Wall, But…

  • @ljmac

    Participant

    After going through the very many posts and requests for this feature, I finally came across a piece of code that allowed me to pull this off in BP 1.7. The only problem is, it requires modification of a BP core file (bp-activity-template.php) – can anybody tell me how to implement this as a bp-custom.php function? The original code from Chris Clayton is here:

    http://buddypress.org/support/topic/how-can-i-get-the-activity-like-facebooks/#post-146620

    After much trial and error, I figured out how to add follow functionality to the code – here is my final code:

    
    case 'wall':
    	if ( bp_is_active( 'friends' && 'bp-follow' ) )
    		$following = bp_follow_get_following( array( 'user_id' => $user_id ) );
    		$friends = friends_get_friend_user_ids( $user_id );
    		$me = array( bp_loggedin_user_id() );
    		$wall = array_merge_recursive( $following, $friends, $me );
    		if ( empty( $wall ) )
    			return false;
    
    		$user_id = implode( ',', (array) $wall );
    	$display_comments = true;
    	break;
    

    This has to be inserted in the scope array starting on line 387 (BP 1.7.1). You also have to add the scope name to the list starting on line 375.

    Once again, if somebody can figure out how to implement this as bp-custom.php function, please let me know. A very big thankyou to Chris Clayton for this code!

Viewing 18 replies - 1 through 18 (of 18 total)
  • @ljmac

    Participant

    I should have mentioned that to use this code, you insert the scope in a custom activity loop, as per https://codex.buddypress.org/developer/developer-docs/loops-reference/the-activity-stream-loop/ – in this case, the loop would be:

    <?php if ( bp_has_activities( 'scope=wall' ) ) : ?>

    @shanebp

    Moderator

    sorry, wrong thread

    @shanebp

    Moderator

    Actually, in bp-activity=template -> bp_has_activities, there is a filter ‘user_id’ that accepts a csv string.
    You shouldn’t need to hack that file.

    Did you try getting friends & followers and then passing that into bp_has_activities ?

    Something like:

    $user_ids = 'user_id=' . $csv_string . "'"; 
    if ( bp_has_activities( $user_ids ) )

    @ljmac

    Participant

    Hi Shane,

    Thanks for your suggestion, but with my very limited level of coding knowledge, I need a little bit more than ‘something like’ to be able to make code work. 🙂 Also, AFAIK a new scope needs to be created to do this reliably – can that be done via the means you’re suggesting? Once again, if somebody can give me a fairly detailed way to convert this code into an external function I would be very grateful, as I’m sure would many other BP users, judging from the number of requests for this feature. It’s a obvious candidate for a plug-in – I know there’s already a premium plug-in for this, but that only works in the profile component, whereas I think most people want this functionality in the main activity stream. Or even better, it should just be part of BP core (the obvious way to do this would be for bp_has_activities to accept multiple scopes, if that’s technically possible).

    @shanebp

    Moderator

    Using ‘scope’ will over-ride any filters, as noted in bp-activity-template.

    There are various ways to makes this a function, but it depends on your install params, hooks etc.

    Following on with your approach, try putting this (untested) at the top of the main activity template.

    
    $user_id = bp_loggedin_user_id();
    $following = array();
    if ( bp_is_active( 'bp-follow') )
    	$following = bp_follow_get_following( array( 'user_id' => $user_id ) );
    
    $friends = array();
    if ( bp_is_active( 'friends') )
    	$friends = friends_get_friend_user_ids( $user_id );
    	
    $me = array( $user_id );
    $wall = array_merge( $following, $friends, $me );
    $wall = array_unique( $wall );
    $user_ids = implode( ',', $wall );
    $get_users = "'user_id=" . $user_ids . "'"; 
    
    if ( bp_has_activities( $get_users ) )
    	//etc

    @ljmac

    Participant

    Hi Shane,

    Just to clarify, would I simply stick this in at the top of my customised version of bp-legacy/buddypress/activity/index.php? There isn’t any need to modify the scope of the activity loop itself?

    @ljmac

    Participant

    Okay, I tried your code, both in the activity template and in place of the activity loop, and in either case, it does nothing – it simply spits out all activity. Thanks for trying though anyway!

    @luckyrajiv

    Participant

    After Adding this

    <?php if ( bp_has_activities( ‘scope=wall’ ) ) : ?>

    by replacing this line

    <?php if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ) ) ) : ?>

    in theme/activity/activity-loop.php

    It shows the Wall in Personal Sub-Nav, But it does show me and my friends updates.

    The Problem is after scrolling down the page it shows LOAD MORE, and when clicked it shows the same Last 20 Updates every time i click LOAD MORE, rather than showing Old 20 Updates.

    Ex: if i have a to h when i click load more it should show i to z , but it shows a-h again and again.

    PLEASE HELP.

    @ljmac

    Participant

    Hi luckyrajiv.

    Did you add the code from my first post to bp-activity-template.php? This is necessary for it to work.

    @bphelp

    Participant

    @ljmac @luckyrajiv
    You can try this plugin but I quit updating it because I felt it was obsolete.
    https://github.com/bphelp/activity-privacy-component

    @luckyrajiv

    Participant

    @ljmac yes, i had added the code to bp-activity-template.php.

    @ljmac

    Participant

    Did you add wall to the list of scope names in bp-activity-template.php as well?

    @bphelp

    Participant

    @luckyrajiv
    Try the plugin in the link I provided instead off editing core files. It is safer to use the plugin. Last time I checked it was working with BP 1.7.2 however I cant promise it will work when BP 1.8 is released and I do not have plans to further update it.

    @luckyrajiv

    Participant

    @ljmac It works now, but one problem, I had to remove this line

    		$following = bp_follow_get_following( array( 'user_id' => $user_id ) );
    

    After this it works, but one more problem, Now all Personal , Favorites, Groups, Mentions have the same stream like wall.

    What i have actually done See here:
    At bp-activty-template.php I added

    	if ( 'wall' == $scope || 'just-me' == $scope || 'friends' == $scope || 'groups' == $scope || 'favorites' == $scope || 'mentions' == $scope ) {
    

    then

    			switch ( $scope ) {
    				case 'wall':
    					if ( bp_is_active( 'friends' && 'bp-follow' ) )
    						$friends = friends_get_friend_user_ids( $user_id );
    						$me = array( bp_loggedin_user_id() );
    						$wall = array_merge_recursive( $friends, $me );
    						if ( empty( $wall ) )
    					return false;
    						$user_id = implode( ',', (array) $wall );
    						$display_comments = true;
    					break;	
    					
    				case 'friends':
    					if ( bp_is_active( 'friends' ) )
    						$friends = friends_get_friend_user_ids( $user_id );
    						if ( empty( $friends ) )
    							return false;
    
    						$user_id = implode( ',', (array) $friends );
    					break;
    

    And After that i Replace the line in Theme/Activity/activity-loop.php

    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ).'&scope=wall' ) ) : ?>
    

    @ljmac

    Participant

    Ah yes – that line should only be there if you’re running BuddyPress Followers. Also, the following line:

    $wall = array_merge_recursive( $following, $friends, $me );

    Should be changed to:

    $wall = array_merge_recursive( $friends, $me );

    On my site, I have set up a separate activity stream for the Wall; if you apply it across your entire site in the way you have, it will restrict ALL activity to the personal Wall. Basically, if you want a normal activity stream AND a personal Wall, you have to set up two separate activity stream pages with different scopes (one universal, and another just for the Wall).

    @luckyrajiv

    Participant

    Yes, I have Added another Stream as a Wall for Activity rather than using Personal.

    Thanks.

    @brikou

    Participant

    Hi Guys,

    @shanebp
    proposition was correct, hi just missed some quotes.
    I personnaly use it like this (in my own activity-loop.php) with somme custom actions.

    		$user_id = bp_loggedin_user_id();
    		$friends = array();
    		if ( bp_is_active( 'friends') )
    			$friends = friends_get_friend_user_ids( $user_id );
    		$me = array( $user_id );
    		$wall = array_merge($friends, $me );
    		$wall = array_unique( $wall );
    		$user_ids = implode( ',', $wall );
    		$get_users = "user_id=" . $user_ids; 
    		$stream_filter = '&'.$get_users.'&action=activity_update,rtmedia_update,new_blog_post,joined_group,created_group';

    then

    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ).$stream_filter ) ) : ?>
    

    cheers and thanks for your help 😉

    @smoothkush

    Participant

    Thank you guys, from the solutions above, I sum up this code :

    Put in activity/index.php –

    At the top of the activity/index.php, paste this code –

    <?php
    //best practice is to create a function in another file, but this will work…
    $friends = bp_follow_get_following( ‘&user_id=’ . bp_loggedin_user_id() );
    $friends[] = bp_loggedin_user_id();
    $friends_and_me = implode( ‘,’, (array) $friends );
    $friends_and_me = ‘&user_id=’ . $friends_and_me;
    ?>

    After that paste this code

    <?php if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ) . $friends_and_me .’&object=groups,friends,status,blogs’) ) : ?>

    Note : I am using buddypress follower plugins. If you are not using the plugin, you need to change this line of code
    – ‘$friends = bp_follow_get_following( ‘&user_id=’ . bp_loggedin_user_id() );’

    to this

    – ‘$friends = friends_get_friend_user_ids( $user_id );’

Viewing 18 replies - 1 through 18 (of 18 total)
  • The topic ‘I've Figured Out How To Create a Facebook-Style Wall, But…’ is closed to new replies.
Skip to toolbar