BuddyDev

Search

[Resolved] Filter Only Videos from Buddypress Activity

  • Participant
    Level: Enlightened
    Posts: 83
    Princy Cromacio on #42408

    Hi There, Is It Possible to Filter only Videos from Buddypress Activity Stream and Place Those Filtered Posts on a Seperate Page?

    I Mean Something Like A Page Known as Videos Or Something, which Will Contain Only Videos from Sitewide Activity.

  • Keymaster
    (BuddyDev Team)
    Posts: 21067
    Brajesh Singh on #42434

    Hi Cromacio,
    Thank you for the question.

    It will depend on how the videos are being added. Is the video uploading/adding creates new activity type? If yes, It can be easily filtered.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 83
    Princy Cromacio on #42444

    Hi Brajesh, Thanks for Reply.
    Unfortunately, It Doesn’t Seem that a New Activity Type is Created based on Videos.
    Do I Need to Do Something to Create New Activity Types on Adding Videos? Or Any Can It Still Be Filtered Directly?
    Thank You 🙂

  • Participant
    Level: Enlightened
    Posts: 83
    Princy Cromacio on #42445

    A Thing More, I Use the Following Code from Your Posts –

    
    
    function buddydev_friends_only_activity_args( $args ) {
    	
    	if( ! bp_is_activity_directory() || !  is_user_logged_in() ) {
    		return $args;
    	}
    	
    	$user_id = get_current_user_id();
    	$user_id_admin = 1;
    	$user_id_manager = 32;
    	$user_ids = friends_get_friend_user_ids( $user_id );
    	
    	//include users own too?
    	array_push( $user_ids, $user_id, $user_id_admin, $user_id_manager);
    	
    	$args['user_id'] = $user_ids;
    	
    	//print_r($args);
    	return $args;
    
    }
    add_filter( 'bp_after_has_activities_parse_args', 'buddydev_friends_only_activity_args' )
    
    

    Can I Make Everything Visible to the Admin Account, I Mean No Filtering Happens when An Admin user is Logged In (or User with User ID= 1) and Admin Sees All Activites.
    Adding Something Like ‘If Is User ID 1 then Do Not Return Args’ ?
    Any Other Suggestions regarding the Code I Already Use is Appreciated too.

    Thank You,
    Cromacio

  • Keymaster
    (BuddyDev Team)
    Posts: 21067
    Brajesh Singh on #42456

    Hi Cromacio,
    Thank you for the reply.

    1. In order to filter the activity, we need some way to identify the videos( either via component or type or any other attribute of the activity, search by string may work but does not feel the right approach )

    2. Please change this line

    
    
    if( ! bp_is_activity_directory() || !  is_user_logged_in() ) {
    		return $args;
    	}
    
    

    to

    
    if( ! bp_is_activity_directory() || !  is_user_logged_in() || is_super_admin() ) {
    		return $args;
    	}
    
    

    That will avoid filtering for super admins.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 83
    Princy Cromacio on #42457

    Hi Brajesh,
    Thanks for Reply (Even on Weekends😅)

    Will Look into Something that Will Create A New Activity Type or Something.
    Updated the Next Line of Code, Thanks for That 🙂

    Cromacio

  • Keymaster
    (BuddyDev Team)
    Posts: 21067
    Brajesh Singh on #42479

    Hi Cromacio,
    You are welcome 🙂

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: resolved