Powered By Blogger
Showing posts with label activity. Show all posts
Showing posts with label activity. Show all posts

Monday, August 21, 2017

custom activity in buddypress OR mentions add in activity feed


do_action( 'bp_before_directory_activity' );
do_action( 'bp_before_directory_activity_content' );
do_action( 'template_notices' );


$userIdd = bp_loggedin_user_id();
$sql = "SELECT leader_id, follower_id FROM wp_bp_follow WHERE follower_id=$userIdd OR leader_id = $userIdd";
$followers = $wpdb->get_col( $sql );
$friends_and_me =  '&user_id=' . $followers;
$followers = array_unique($followers);
$followers[] = bp_loggedin_user_id();
$friends_and_me = implode( ',', (array) $followers );
$friends_and_me =  '&user_id=' . $friends_and_me;

global $bp;
$bp->current_action = array('public');

if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . $friends_and_me) ) :

while ( bp_activities() ) : bp_the_activity();
$activity_id = bp_get_activity_id();
if ( !empty( $activity_id ) ) {
$the_act_list .=  $activity_id.',';
}

endwhile;
endif;

$bp->current_action = array('mentions');

if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . $friends_and_me) ) :

while ( bp_activities() ) : bp_the_activity();
if ( !empty( bp_get_activity_id() ) ) {
$the_mention_act_list .=  bp_get_activity_id().',';

}
 
endwhile;
endif;
$the_act_list = rtrim($the_act_list,',');
$the_mention_act_list = rtrim($the_mention_act_list,',');
$the_act_list = $the_act_list.','.$the_mention_act_list;
$activitlistttt = 'include='.$the_act_list.'&max=20';



if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . $activitlistttt) ) :

while ( bp_activities() ) : bp_the_activity();
  locate_template( array( 'buddypress/activity/entry.php' ), true, false );
endwhile;
endif;




do_action( 'bp_after_directory_activity_list' );
do_action( 'bp_directory_activity_content' );
do_action( 'bp_after_directory_activity_content' );
do_action( 'bp_after_directory_activity' ); 

Sunday, May 21, 2017

use user activity in custom template in buddypress

<?php

 if($memberId == get_current_user_id()) {
locate_template( 'buddypress/activity/index.php',true );
}

?>





<?php
do_action( 'bp_before_directory_activity' );
do_action( 'bp_before_directory_activity_content' );
do_action( 'template_notices' );
?>
<?php if ( is_user_logged_in() ) : ?>
<?php if(bp_displayed_user_id() == get_current_user_id()){ ?>
<?php bp_get_template_part( 'buddypress/activity/post-form' ); ?>
<?php } ?>
<?php endif; ?>



<?php
global $wpdb;
$userIdd = bp_loggedin_user_id();
$sql = "SELECT leader_id FROM sf_bp_follow WHERE follower_id=$userIdd";
$followers = $wpdb->get_col( $sql );
$friends_and_me =  '&user_id=' . $followers;
$followers = array_unique($followers);
$followers[] = bp_loggedin_user_id();
$friends_and_me = implode( ',', (array) $followers );
$friends_and_me =  '&user_id=' . $friends_and_me;
?>

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

<?php //if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) : ?>
   <?php while ( bp_activities() ) : bp_the_activity(); ?>

       <?php locate_template( array( 'buddypress/activity/entry.php' ), true, false ); ?>

   <?php endwhile; ?>
<?php endif; ?>

<?php

/**
* Fires after the display of the activity list.
*
* @since 1.5.0
*/
do_action( 'bp_after_directory_activity_list' ); ?>

<?php

/**
* Fires inside and displays the activity directory display content.
*/
do_action( 'bp_directory_activity_content' ); ?>

<?php

/**
* Fires after the activity directory display content.
*
* @since 1.2.0
*/
do_action( 'bp_after_directory_activity_content' ); ?>

<?php

/**
* Fires after the activity directory listing.
*
* @since 1.5.0
*/
do_action( 'bp_after_directory_activity' ); ?>