• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP bp_get_user_last_activity函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中bp_get_user_last_activity函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_get_user_last_activity函数的具体用法?PHP bp_get_user_last_activity怎么用?PHP bp_get_user_last_activity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了bp_get_user_last_activity函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: bp_core_record_activity

/**
 * Listener function for the logged-in user's 'last_activity' metadata.
 *
 * Many functions use a "last active" feature to show the length of time since
 * the user was last active. This function will update that time as a usermeta
 * setting for the user every 5 minutes while the user is actively browsing the
 * site.
 *
 * @uses bp_update_user_meta() BP function to update user metadata in the
 *       usermeta table.
 *
 * @return bool|null Returns false if there is nothing to do.
 */
function bp_core_record_activity()
{
    // Bail if user is not logged in
    if (!is_user_logged_in()) {
        return false;
    }
    // Get the user ID
    $user_id = bp_loggedin_user_id();
    // Bail if user is not active
    if (bp_is_user_inactive($user_id)) {
        return false;
    }
    // Get the user's last activity
    $activity = bp_get_user_last_activity($user_id);
    // Make sure it's numeric
    if (!is_numeric($activity)) {
        $activity = strtotime($activity);
    }
    // Get current time
    $current_time = bp_core_current_time();
    // Use this action to detect the very first activity for a given member
    if (empty($activity)) {
        do_action('bp_first_activity_for_member', $user_id);
    }
    // If it's been more than 5 minutes, record a newer last-activity time
    if (empty($activity) || strtotime($current_time) >= strtotime('+5 minutes', $activity)) {
        bp_update_user_last_activity($user_id, $current_time);
    }
}
开发者ID:antares-ff,项目名称:ANTARES-Test,代码行数:42,代码来源:bp-core-functions.php


示例2: user_admin_stats_metabox

        /**
         * Render the Stats metabox to moderate inappropriate images.
         *
         * @since 2.0.0
         *
         * @param WP_User|null $user The WP_User object to be edited.
         */
        public function user_admin_stats_metabox($user = null)
        {
            // Bail if no user ID.
            if (empty($user->ID)) {
                return;
            }
            // If account is not activated last activity is the time user registered.
            if (isset($user->user_status) && 2 == $user->user_status) {
                $last_active = $user->user_registered;
                // Account is activated, getting user's last activity.
            } else {
                $last_active = bp_get_user_last_activity($user->ID);
            }
            $datef = __('M j, Y @ G:i', 'buddypress');
            $date = date_i18n($datef, strtotime($last_active));
            ?>

		<ul>
			<li class="bp-members-profile-stats"><?php 
            printf(__('Last active: %1$s', 'buddypress'), '<strong>' . $date . '</strong>');
            ?>
</li>

			<?php 
            // Loading other stats only if user has activated their account.
            if (empty($user->user_status)) {
                /**
                 * Fires in the user stats metabox if the user has activated their account.
                 *
                 * @since 2.0.0
                 *
                 * @param array  $value Array holding the user ID.
                 * @param object $user  Current displayed user object.
                 */
                do_action('bp_members_admin_user_stats', array('user_id' => $user->ID), $user);
            }
            ?>
		</ul>

		<?php 
        }
开发者ID:buddypress,项目名称:BuddyPress-build,代码行数:48,代码来源:class-bp-members-admin.php


示例3: _bp_get_user_meta_last_activity_warning

/**
 * Backward compatibility for 'last_activity' usermeta fetching.
 *
 * In BuddyPress 2.0, user last_activity data was moved out of usermeta. For
 * backward compatibility, we continue to mirror the data there. This function
 * serves two purposes: it warns plugin authors of the change, and it returns
 * the data from the proper location.
 *
 * @since 2.0.0
 *
 * @access private For internal use only.
 *
 * @param null   $retval Null retval value.
 * @param int    $object_id ID of the user.
 * @param string $meta_key  Meta key being fetched.
 * @return mixed
 */
function _bp_get_user_meta_last_activity_warning($retval, $object_id, $meta_key)
{
    static $warned = false;
    if ('last_activity' === $meta_key) {
        // Don't send the warning more than once per pageload.
        if (false === $warned) {
            _doing_it_wrong('get_user_meta( $user_id, \'last_activity\' )', __('User last_activity data is no longer stored in usermeta. Use bp_get_user_last_activity() instead.', 'buddypress'), '2.0.0');
            $warned = true;
        }
        return bp_get_user_last_activity($object_id);
    }
    return $retval;
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:30,代码来源:bp-members-functions.php


示例4: populate

 /**
  * Populate the instantiated class with data based on the User ID provided.
  *
  * @uses bp_core_get_userurl() Returns the URL with no HTML markup for
  *       a user based on their user id.
  * @uses bp_core_get_userlink() Returns a HTML formatted link for a
  *       user with the user's full name as the link text.
  * @uses bp_core_get_user_email() Returns the email address for the
  *       user based on user ID.
  * @uses bp_get_user_meta() BP function returns the value of passed
  *       usermeta name from usermeta table.
  * @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user
  * @uses bp_profile_last_updated_date() Returns the last updated date
  *       for a user.
  */
 public function populate()
 {
     if (bp_is_active('xprofile')) {
         $this->profile_data = $this->get_profile_data();
     }
     if (!empty($this->profile_data)) {
         $full_name_field_name = bp_xprofile_fullname_field_name();
         $this->user_url = bp_core_get_user_domain($this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login']);
         $this->fullname = esc_attr($this->profile_data[$full_name_field_name]['field_data']);
         $this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
         $this->email = esc_attr($this->profile_data['user_email']);
     } else {
         $this->user_url = bp_core_get_user_domain($this->id);
         $this->user_link = bp_core_get_userlink($this->id);
         $this->fullname = esc_attr(bp_core_get_user_displayname($this->id));
         $this->email = esc_attr(bp_core_get_user_email($this->id));
     }
     // Cache a few things that are fetched often
     wp_cache_set('bp_user_fullname_' . $this->id, $this->fullname, 'bp');
     wp_cache_set('bp_user_email_' . $this->id, $this->email, 'bp');
     wp_cache_set('bp_user_url_' . $this->id, $this->user_url, 'bp');
     $this->avatar = bp_core_fetch_avatar(array('item_id' => $this->id, 'type' => 'full', 'alt' => sprintf(__('Profile photo of %s', 'buddypress'), $this->fullname)));
     $this->avatar_thumb = bp_core_fetch_avatar(array('item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf(__('Profile photo of %s', 'buddypress'), $this->fullname)));
     $this->avatar_mini = bp_core_fetch_avatar(array('item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf(__('Profile photo of %s', 'buddypress'), $this->fullname), 'width' => 30, 'height' => 30));
     $this->last_active = bp_core_get_last_activity(bp_get_user_last_activity($this->id), __('active %s', 'buddypress'));
 }
开发者ID:kosir,项目名称:thatcamp-org,代码行数:41,代码来源:class-bp-core-user.php


示例5: bp_get_last_activity

/**
 * Get the "active [x days ago]" string for a user.
 *
 * @param int $user_id ID of the user. Default: displayed user ID.
 * @return string
 */
function bp_get_last_activity($user_id = 0)
{
    if (empty($user_id)) {
        $user_id = bp_displayed_user_id();
    }
    $last_activity = bp_core_get_last_activity(bp_get_user_last_activity($user_id), __('active %s', 'buddypress'));
    /**
     * Filters the 'active [x days ago]' string for a user.
     *
     * @since 1.5.0
     *
     * @param string $value Formatted 'active [x days ago]' string.
     */
    return apply_filters('bp_get_last_activity', $last_activity);
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:21,代码来源:bp-members-template.php


示例6: test_bp_last_activity_migrate

 /**
  * @group bp_last_activity_migrate
  * @expectedIncorrectUsage update_user_meta( $user_id, 'last_activity' )
  * @expectedIncorrectUsage get_user_meta( $user_id, 'last_activity' )
  */
 public function test_bp_last_activity_migrate()
 {
     // We explicitly do not want last_activity created, so use the
     // WP factory methods
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $u3 = $this->factory->user->create();
     $time = time();
     $t1 = date('Y-m-d H:i:s', $time - 50);
     $t2 = date('Y-m-d H:i:s', $time - 500);
     $t3 = date('Y-m-d H:i:s', $time - 5000);
     update_user_meta($u1, 'last_activity', $t1);
     update_user_meta($u2, 'last_activity', $t2);
     update_user_meta($u3, 'last_activity', $t3);
     // Create an existing entry in last_activity to test no dupes
     global $wpdb;
     $bp = buddypress();
     $wpdb->query($wpdb->prepare("INSERT INTO {$bp->members->table_name_last_activity}\n\t\t\t\t(`user_id`, `component`, `type`, `action`, `content`, `primary_link`, `item_id`, `date_recorded` ) VALUES\n\t\t\t\t( %d, %s, %s, %s, %s, %s, %d, %s )", $u2, $bp->members->id, 'last_activity', '', '', '', 0, $t1));
     bp_last_activity_migrate();
     $expected = array($u1 => $t1, $u2 => $t2, $u3 => $t3);
     $found = array($u1 => '', $u2 => '', $u3 => '');
     foreach ($found as $uid => $v) {
         $found[$uid] = bp_get_user_last_activity($uid);
     }
     $this->assertSame($expected, $found);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:31,代码来源:functions.php


示例7: manage_users_custom_column

 public function manage_users_custom_column($empty, $column_name, $user_id)
 {
     if ('timestamps' != $column_name) {
         return $empty;
     }
     global $gMemberNetwork;
     $html = '';
     $mode = empty($_REQUEST['mode']) ? 'list' : $_REQUEST['mode'];
     $user = get_user_by('id', $user_id);
     $lastlogin = get_user_meta($user_id, $this->constants['meta_lastlogin'], TRUE);
     $register_ip = get_user_meta($user_id, $this->constants['meta_register_ip'], TRUE);
     $registered = strtotime(get_date_from_gmt($user->user_registered));
     $lastlogged = $lastlogin ? strtotime(get_date_from_gmt($lastlogin)) : NULL;
     $html .= '<table></tbody>';
     $html .= '<tr><td>' . __('Registered', GMEMBER_TEXTDOMAIN) . '</td><td><code title="' . $gMemberNetwork->getDate($registered, 'timeampm') . '">' . $gMemberNetwork->getDate($registered) . '</code></td></tr>';
     $html .= '<tr><td>' . __('Last Login', GMEMBER_TEXTDOMAIN) . '</td><td>' . ($lastlogin ? '<code title="' . $gMemberNetwork->getDate($lastlogged, 'timeampm') . '">' . $gMemberNetwork->getDate($lastlogged) . '</code>' : '<code>' . __('N/A', GMEMBER_TEXTDOMAIN)) . '</code></td></tr>';
     if (function_exists('bp_get_user_last_activity')) {
         if ($lastactivity = bp_get_user_last_activity($user_id)) {
             $lastactive = strtotime(get_date_from_gmt($lastactivity));
         }
         $html .= '<tr><td>' . __('Last Activity', GMEMBER_TEXTDOMAIN) . '</td><td>' . ($lastactivity ? '<code title="' . bp_core_time_since($lastactivity) . '">' . $gMemberNetwork->getDate($lastactive) : '<code>' . __('N/A', GMEMBER_TEXTDOMAIN)) . '</code></td></tr>';
     }
     $html .= '<tr><td>' . __('Register IP', GMEMBER_TEXTDOMAIN) . '</td><td><code>' . ($register_ip ? $gMemberNetwork->getIPLookup($register_ip) : __('N/A', GMEMBER_TEXTDOMAIN)) . '</code></td></tr>';
     $html .= '</tbody></table>';
     echo $html;
 }
开发者ID:geminorum,项目名称:gmember,代码行数:26,代码来源:admin.class.php


示例8: bp_core_record_activity

/**
 * Listener function for the logged-in user's 'last_activity' metadata.
 *
 * Many functions use a "last active" feature to show the length of time since
 * the user was last active. This function will update that time as a usermeta
 * setting for the user every 5 minutes while the user is actively browsing the
 * site.
 *
 * @uses bp_update_user_meta() BP function to update user metadata in the
 *       usermeta table.
 *
 * @return bool|null Returns false if there is nothing to do.
 */
function bp_core_record_activity()
{
    // Bail if user is not logged in
    if (!is_user_logged_in()) {
        return false;
    }
    // Get the user ID
    $user_id = bp_loggedin_user_id();
    // Bail if user is not active
    if (bp_is_user_inactive($user_id)) {
        return false;
    }
    // Get the user's last activity
    $activity = bp_get_user_last_activity($user_id);
    // Make sure it's numeric
    if (!is_numeric($activity)) {
        $activity = strtotime($activity);
    }
    // Get current time
    $current_time = bp_core_current_time();
    // Use this action to detect the very first activity for a given member
    if (empty($activity)) {
        /**
         * Fires inside the recording of an activity item.
         *
         * Use this action to detect the very first activity for a given member.
         *
         * @since BuddyPress (1.6.0)
         *
         * @param int $user_id ID of the user whose activity is recorded.
         */
        do_action('bp_first_activity_for_member', $user_id);
    }
    // If it's been more than 5 minutes, record a newer last-activity time
    if (empty($activity) || strtotime($current_time) >= strtotime('+5 minutes', $activity)) {
        bp_update_user_last_activity($user_id, $current_time);
    }
}
开发者ID:AceMedia,项目名称:BuddyPress,代码行数:51,代码来源:bp-core-functions.php


示例9: user_admin_stats_metabox

        /**
         * Render the Stats metabox to moderate inappropriate images.
         *
         * @access public
         * @since BuddyPress (2.0.0)
         *
         * @param WP_User $user The WP_User object to be edited.
         */
        public function user_admin_stats_metabox($user = null)
        {
            if (empty($user->ID)) {
                return;
            }
            // If account is not activated last activity is the time user registered
            if (isset($user->user_status) && 2 == $user->user_status) {
                $last_active = $user->user_registered;
                // Account is activated, getting user's last activity
            } else {
                $last_active = bp_get_user_last_activity($user->ID);
            }
            $datef = __('M j, Y @ G:i', 'buddypress');
            $date = date_i18n($datef, strtotime($last_active));
            ?>

		<ul>
			<li class="bp-members-profile-stats"><?php 
            printf(__('Last active: <strong>%1$s</strong>', 'buddypress'), $date);
            ?>
</li>

			<?php 
            // Loading other stats only if user has activated their account
            if (empty($user->user_status)) {
                do_action('bp_members_admin_user_stats', array('user_id' => $user->ID), $user);
            }
            ?>
		</ul>

		<?php 
        }
开发者ID:danielcoats,项目名称:schoolpress,代码行数:40,代码来源:bp-members-admin.php


示例10: bp_get_last_activity

/**
 * Get the "active [x days ago]" string for a user.
 *
 * @param int $user_id ID of the user. Default: displayed user ID.
 * @return string
 */
function bp_get_last_activity($user_id = 0)
{
    if (empty($user_id)) {
        $user_id = bp_displayed_user_id();
    }
    $last_activity = bp_core_get_last_activity(bp_get_user_last_activity($user_id), __('active %s', 'buddypress'));
    return apply_filters('bp_get_last_activity', $last_activity);
}
开发者ID:eresyyl,项目名称:mk,代码行数:14,代码来源:bp-members-template.php


示例11: do_action

			<?php 
}
?>

			<div id="item-buttons"><?php 
/**
 * Fires in the member header actions section.
 *
 * @since 1.2.6
 */
do_action('bp_member_header_actions');
?>
</div><!-- #item-buttons -->

			<span class="activity" data-livestamp="<?php 
bp_core_iso8601_date(bp_get_user_last_activity(bp_displayed_user_id()));
?>
"><?php 
bp_last_activity(bp_displayed_user_id());
?>
</span>

			<?php 
/**
 * Fires before the display of the member's header meta.
 *
 * @since 1.2.0
 */
do_action('bp_before_member_header_meta');
?>
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:30,代码来源:cover-image-header.php


示例12: generate_data


//.........这里部分代码省略.........
         // loop over each field ##
         foreach ($fields as $field) {
             // check if this is a BP field ##
             if (isset($bp_data) && isset($bp_data[$field]) && in_array($field, $bp_fields_passed)) {
                 // old way from single BP query ##
                 $value = $bp_data[$field];
                 if (is_array($value)) {
                     $value = maybe_unserialize($value['field_data']);
                     // suggested by @grexican ##
                     #$value = $value['field_data'];
                     /**
                      * cwjordan
                      * after unserializing it we then 
                      * need to implode it so 
                      * that we have something readable?
                      * Going to use :: as a separator
                      * because that's what Buddypress Members Import
                      * expects, but we might want to make that 
                      * configurable. 
                      */
                     if (is_array($value)) {
                         $value = implode("::", $value);
                     }
                 }
                 $value = self::sanitize($value);
                 // check if this is a BP field we want the updated date for ##
             } elseif (in_array($field, $bp_fields_update_passed)) {
                 global $bp;
                 $real_field = str_replace(" Update Date", "", $field);
                 $field_id = xprofile_get_field_id_from_name($real_field);
                 $value = $wpdb->get_var($wpdb->prepare("\n                                            SELECT last_updated \n                                            FROM {$bp->profile->table_name_data} \n                                            WHERE user_id = %d AND field_id = %d\n                                        ", $user->ID, $field_id));
                 // include the user's role in the export ##
             } elseif (isset($_POST['roles']) && '1' == $_POST['roles'] && $field == 'roles') {
                 // add "Role" as $value ##
                 $value = isset($user->roles[0]) ? implode($user->roles, '|') : '';
                 // empty value if no role found - or flat array of user roles ##
                 // include the user's BP group in the export ##
             } elseif (isset($_POST['groups']) && '1' == $_POST['groups'] && $field == 'groups') {
                 if (function_exists('groups_get_user_groups')) {
                     // check if user is a member of any groups ##
                     $group_ids = groups_get_user_groups($user->ID);
                     #self::pr( $group_ids );
                     #wp_die( pr( 'loaded group data.' ));
                     if (!$group_ids || $group_ids == '') {
                         $value = '';
                     } else {
                         // new empty array ##
                         $groups = array();
                         // loop over all groups ##
                         foreach ($group_ids["groups"] as $group_id) {
                             $groups[] = groups_get_group(array('group_id' => $group_id))->name . (end($group_ids["groups"]) == $group_id ? '' : '');
                         }
                         // implode it ##
                         $value = implode($groups, '|');
                     }
                 } else {
                     $value = '';
                 }
             } elseif ($field == 'bp_latest_update') {
                 // https://bpdevel.wordpress.com/2014/02/21/user-last_activity-data-and-buddypress-2-0/ ##
                 $value = bp_get_user_last_activity($user->ID);
                 // user or usermeta field ##
             } else {
                 // the user_meta key isset ##
                 if (isset($get_user_meta[$field])) {
                     // take from the bulk get_user_meta call - this returns an array in all cases, so we take the first key ##
                     $value = $get_user_meta[$field][0];
                     // standard WP_User value ##
                 } else {
                     // use the magically assigned value from WP_Users
                     $value = $user->{$field};
                 }
                 // the $value might be serialized ##
                 $value = self::unserialize($value);
                 // the value is an array ##
                 if (is_array($value)) {
                     // recursive implode it ##
                     $value = self::recursive_implode($value);
                 }
             }
             // correct program value to Program Name ##
             if ($field == 'member_of_club') {
                 $value = get_the_title($value);
             }
             // wrap values in quotes and add to array ##
             if ($is_csv) {
                 $data[] = '"' . str_replace('"', '""', self::special_characters($value)) . '"';
                 // just add to array ##
             } else {
                 $data[] = self::special_characters($value);
             }
         }
         // echo row data ##
         echo $pre . implode($seperator, $data) . $breaker;
     }
     // close doc wrapper..
     echo $doc_end;
     // stop PHP, so file can export correctly ##
     exit;
 }
开发者ID:adnandot,项目名称:intenseburn,代码行数:101,代码来源:export-user-data.php



注:本文中的bp_get_user_last_activity函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP bp_get_user_meta函数代码示例发布时间:2022-05-24
下一篇:
PHP bp_get_user_has_avatar函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap