custom members loop
-
Hi guys, ive managed to almost get where I need to go with this thanks to the great explanations and code examples on these forums but Im stuck at the final hurdle! Basically what Im trying to create is an “in/out” board on our intranet which is a single page on the site which loops through all users and displays their last status update. All our staff will then use the status update function to update their whereabouts, eg “at lunch back at 2” or “meeting offsite until 3”
Ive managed to create a custom page template with a hacked up version of the members loop which so far gives me the avatar, username and last status update, but the final thing I need is the time/date of the last status update instead of the time the user was last active.
I could do this in the activity loop and Ive created a function in my functions.php to format the date the way I want it, but it seems this does not apply to the members loop.here is the code I am using in my page template:
<?php /* Template Name: In Out Page */ ?> <?php get_header(); ?> <div class="sleeve_main"> <div id="main"> <h2><?php the_title(); ?></h2> <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?> <?php do_action( 'bp_before_directory_members_list' ); ?> <ul id="members-list" class="item-list" role="main"> <?php while ( bp_members() ) : bp_the_member(); ?> <li> <div class="item-avatar"> <?php bp_member_avatar(); ?> <?php bp_member_name(); ?> </div> <div class="item"> <div class="item-title"> <?php if ( bp_get_member_latest_update() ) : ?> <span class="update"><?php bp_member_latest_update(array( 'view_link' => false )); ?></span> <?php endif; ?> </div> <div class="item-meta"><span class="activity"><?php bp_member_last_active(); ?></span></div> <?php do_action( 'bp_directory_members_item' ); ?> </div> <div class="action"> <?php do_action( 'bp_directory_members_actions' ); ?> </div> <div class="clear"></div> </li> <?php endwhile; ?> </ul> <?php do_action( 'bp_after_directory_members_list' ); ?> <?php bp_member_hidden_fields(); ?> <?php else: ?> <div id="message" class="info"> <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p> </div> <?php endif; ?> </div> <!-- main --> </div> <!-- sleeve --> <?php get_footer(); ?>
and this is the code to format the date in my functions.php :
function format_activity_date() { $activityDate=bp_get_activity_date_recorded(); // Get GMT offset from root blog $root_blog_offset = get_blog_option( BP_ROOT_BLOG, 'gmt_offset' ); // Calculate offset time $time_offset = $time + ( $root_blog_offset * 3600 ); // Format the time using the offset and return it; date-i18n retrieves the date in localized format return '' . date_i18n("l, d/m/y, g:ia", strtotime($activityDate) + $time_offset) . ''; } add_filter('bp_activity_time_since', 'format_activity_date');
from what I can tell, I dont want to be using the bp_member_last_active() function as this will return the last time the user did anything. Rather, I need to use some other function which will return the timestamp of the users last status update, but I cant get this part to work!
Any help much appreciated
cheers
- The topic ‘custom members loop’ is closed to new replies.