bp_get_member_last_active( array $args = array() )
Return the current member’s last active time.
Description
Parameters
- $args
-
(array) (Optional) Array of optional arguments.
- 'active_format'
(mixed) If true, formatted "active 5 minutes ago". If false, formatted "5 minutes ago". If string, should be sprintf'able like 'last seen %s ago'. - 'relative'
(bool) If true, will return relative time "5 minutes ago". If false, will return date from database. Default: true.
Default value: array()
- 'active_format'
Return
(string)
Source
File: bp-members/bp-members-template.php
function bp_get_member_last_active( $args = array() ) { global $members_template; // Parse the activity format. $r = bp_parse_args( $args, array( 'active_format' => true, 'relative' => true, ) ); // Backwards compatibility for anyone forcing a 'true' active_format. if ( true === $r['active_format'] ) { $r['active_format'] = __( 'active %s', 'buddyboss' ); } // Member has logged in at least one time. if ( isset( $members_template->member->last_activity ) ) { // We do not want relative time, so return now. // @todo Should the 'bp_member_last_active' filter be applied here? if ( ! $r['relative'] ) { return esc_attr( $members_template->member->last_activity ); } // Backwards compatibility for pre 1.5 'ago' strings. $last_activity = ! empty( $r['active_format'] ) ? bp_core_get_last_activity( $members_template->member->last_activity, $r['active_format'] ) : bp_core_time_since( $members_template->member->last_activity ); // Member has never logged in or been active. } else { $last_activity = __( 'Never active', 'buddyboss' ); } /** * Filters the current members last active time. * * @since BuddyPress 1.2.0 * * @param string $last_activity Formatted time since last activity. * @param array $r Array of parsed arguments for query. */ return apply_filters( 'bp_member_last_active', $last_activity, $r ); }
Changelog
Version | Description |
---|---|
BuddyPress 2.7.0 Added 'relative' as a parameter to $args. | BuddyPress 2.7.0 Added 'relative' as a parameter to $args. |
BuddyPress 1.2.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.