BuddyDev

Search

Delete a friend’s post from my timeline/ User face showing when liking a post

  • Participant
    Level: Initiated
    Posts: 17
    Daniel Botoc on #38575

    Good day,

    1. Can you please advise if possible to delete a friend’s post from my timeline. Currently a connection can post on my timeline, however I can not delete it. I can only report it. My friend’s post it will show at ‘My connections’.
    I can delete a comment from a friend but not entire post.

    2. I’ve seen in code snippets that you guys added the possibility to show the user avatar when he/she likes a post in Activity Feed? However, I’ve tried it, but it doesnt work. Added in the child theme/functions.php

    If you can please advise

    Thank you, really appreciate it

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #38576

    Hello Daniel,

    Thank you for posting.

    1. Are you using BuddyPress Or BuddyBoss Platform.
    2. Can you link me to the post where we share the code snippet so that I can help you?.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 17
    Daniel Botoc on #38577
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #38598

    Hello Daniel,

    Thank you for the details.

    1. There is no direct way to implement this with the BuddyBoss Platform. Please contact BuddyBoss they can better guide you with this.

    2. Use the following code:

    
    add_action( 'bp_activity_add_user_favorite', 'bpdev_track_user_favorite', 10, 2 );
    function bpdev_track_user_favorite( $activity_id, $user_id ) {
    	bp_activity_add_meta( $activity_id, 'favorited_by_user', $user_id );
    }
    
    add_action( 'bp_activity_remove_user_favorite', 'bpdev_track_user_unfavorite', 10, 2 );
    function bpdev_track_user_unfavorite( $activity_id, $user_id ) {
    	bp_activity_delete_meta( $activity_id, 'favorited_by_user', $user_id );
    }
    
    //show faces, yay!
    add_action( 'bp_activity_entry_content', 'bpdev_show_who_favorited_activities' );
    function bpdev_show_who_favorited_activities() {
    	$output          = '';
    	$favorited_users = bp_activity_get_meta( bp_get_activity_id(), 'favorited_by_user', false );
    
    	if ( ! empty( $favorited_users ) ) {
    		foreach ( (array) $favorited_users as $user_id ) {
    			$user_domain = bp_core_get_user_domain( $user_id );
    
    			$avatar = bp_core_fetch_avatar(
    				array(
    					'type'    => 'thumb',
    					'height'  => 25,
    					'width'   => 25,
    					'item_id' => $user_id
    				)
    			);
    
    			$output .= sprintf( '<a href="%s">%s</a>', $user_domain, $avatar );
    		}
    	}
    
    	if ( $output ) {
    		echo "<div class='clearfix activity-favorited-by'>{$output}</div>";
    	}
    }
    
    

    Please do let me know if it works or not.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 17
    Daniel Botoc on #38634
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #38644

    Hello Daniel,

    Thank for the details. Yes, It is a problem with the code but I couldn’t help you much with it. Currently, We are busy with some other important projects. But we do have a plan to have this feature in future plugins.

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: not resolved