当前位置: 首页>>代码示例>>PHP>>正文


PHP bp_is_user_inactive函数代码示例

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


在下文中一共展示了bp_is_user_inactive函数的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: bp_global_access_role_mask

/**
 * Add the default role and mapped BuddyPress caps to the current user if needed
 *
 * This function will bail if the community is not global in a multisite
 * installation of WordPress, or if the user is marked as spam or deleted.
 *
 * @since BuddyPress (1.6)
 *
 * @uses is_multisite()
 * @uses bp_allow_global_access()
 * @uses bp_is_user_inactive()
 * @uses is_user_logged_in()
 * @uses current_user_can()
 * @uses get_option()
 * @uses bp_get_caps_for_role()
 *
 * @global BuddyPress $bbp
 * @return If not multisite, not global, or user is deleted/spammed
 */
function bp_global_access_role_mask()
{
    // Bail if not multisite or community is not global
    if (!is_multisite() || !bp_allow_global_access()) {
        return;
    }
    // Bail if user is marked as spam or is deleted
    if (bp_is_user_inactive()) {
        return;
    }
    // Normal user is logged in but has no caps
    if (is_user_logged_in() && !current_user_can('read')) {
        // Define local variable
        $mapped_meta_caps = array();
        // Assign user the minimal participant role to map caps to
        $default_role = bp_get_participant_role();
        // Get BuddyPress caps for the default role
        $caps_for_role = bp_get_caps_for_role($default_role);
        // Set all caps to true
        foreach ($caps_for_role as $cap) {
            $mapped_meta_caps[$cap] = true;
        }
        // Add 'read' cap just in case
        $mapped_meta_caps['read'] = true;
        $mapped_meta_caps['bp_masked'] = true;
        // Allow global access caps to be manipulated
        $mapped_meta_caps = apply_filters('bp_global_access_mapped_meta_caps', $mapped_meta_caps);
        // Assign the role and mapped caps to the current user
        global $bp;
        $bp->current_user->roles[0] = $default_role;
        $bp->current_user->caps = $mapped_meta_caps;
        $bp->current_user->allcaps = $mapped_meta_caps;
    }
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:53,代码来源:bp-core-caps.php

示例3: _bp_enforce_bp_moderate_cap_for_admins

/**
 * Temporary implementation of 'bp_moderate' cap.
 *
 * In BuddyPress 1.6, the 'bp_moderate' cap was introduced. In order to
 * enforce that bp_current_user_can( 'bp_moderate' ) always returns true for
 * Administrators, we must manually add the 'bp_moderate' cap to the list of
 * user caps for Admins.
 *
 * Note that this level of enforcement is only necessary in the case of
 * non-Multisite. This is because WordPress automatically assigns every
 * capability - and thus 'bp_moderate' - to Super Admins on a Multisite
 * installation. See {@link WP_User::has_cap()}.
 *
 * This implementation of 'bp_moderate' is temporary, until BuddyPress properly
 * matches caps to roles and stores them in the database. Plugin authors: Do
 * not use this function.
 *
 * @access private
 * @since BuddyPress (1.6.0)
 *
 * @see WP_User::has_cap()
 *
 * @param array $allcaps The caps that WP associates with the given role.
 * @param array $caps The caps being tested for in WP_User::has_cap().
 * @param array $args Miscellaneous arguments passed to the user_has_cap filter.
 * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant.
 */
function _bp_enforce_bp_moderate_cap_for_admins($caps = array(), $cap = '', $user_id = 0, $args = array())
{
    // Bail if not checking the 'bp_moderate' cap
    if ('bp_moderate' !== $cap) {
        return $caps;
    }
    // Bail if BuddyPress is not network activated
    if (bp_is_network_activated()) {
        return $caps;
    }
    // Never trust inactive users
    if (bp_is_user_inactive($user_id)) {
        return $caps;
    }
    // Only users that can 'manage_options' on this site can 'bp_moderate'
    return array('manage_options');
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:44,代码来源:bp-core-caps.php

示例4: bp_forums_insert_post

/**
 * Create a new post.
 *
 * @param array $args {
 *     @type int $post_id Optional. ID of an existing post, if you want to
 *           update rather than create. Default: false.
 *     @type int $topic_id ID of the topic to which the post belongs.
 *     @type string $post_text Contents of the post.
 *     @type string $post_time Optional. Time when the post was recorded.
 *           Default: current time, as reported by {@link bp_core_current_time()}.
 *     @type int $poster_id Optional. ID of the user creating the post.
 *           Default: ID of the logged-in user.
 *     @type string $poster_ip Optional. IP address of the user creating the
 *           post. Default: the IP address found in $_SERVER['REMOTE_ADDR'].
 *     @type int $post_status Post status. Default: 0.
 *     @type int $post_position Optional. Default: false (auto).
 * }
 * @return int|bool ID of the new post on success, false on failure.
 */
function bp_forums_insert_post($args = '')
{
    /** This action is documented in bp-forums/bp-forums-screens */
    do_action('bbpress_init');
    $defaults = array('post_id' => false, 'topic_id' => false, 'post_text' => '', 'post_time' => bp_core_current_time(), 'poster_id' => bp_loggedin_user_id(), 'poster_ip' => $_SERVER['REMOTE_ADDR'], 'post_status' => 0, 'post_position' => false);
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    if (!($post = bp_forums_get_post($post_id))) {
        $post_id = false;
    }
    if (!isset($topic_id)) {
        $topic_id = $post->topic_id;
    }
    if (empty($post_text)) {
        $post_text = $post->post_text;
    }
    if (!isset($post_time)) {
        $post_time = $post->post_time;
    }
    if (!isset($post_position)) {
        $post_position = $post->post_position;
    }
    if (empty($poster_id)) {
        return false;
    }
    if (bp_is_user_inactive(bp_loggedin_user_id())) {
        return false;
    }
    $post_id = bb_insert_post(array('post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes(trim($post_text)), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position));
    if (!empty($post_id)) {
        /**
         * Fires if there was a new post created.
         *
         * @since BuddyPress (1.0.0)
         *
         * @param int $post_id ID of the newly created forum post.
         */
        do_action('bp_forums_new_post', $post_id);
    }
    return $post_id;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:60,代码来源:bp-forums-functions.php

示例5: bp_activity_post_update

/**
 * Post an activity update.
 *
 * @since BuddyPress (1.2.0)
 *
 * @uses wp_parse_args()
 * @uses bp_is_user_inactive()
 * @uses bp_core_get_userlink()
 * @uses bp_activity_add()
 * @uses apply_filters() To call the 'bp_activity_new_update_action' hook.
 * @uses apply_filters() To call the 'bp_activity_new_update_content' hook.
 * @uses apply_filters() To call the 'bp_activity_new_update_primary_link' hook.
 * @uses bp_update_user_meta()
 * @uses wp_filter_kses()
 * @uses do_action() To call the 'bp_activity_posted_update' hook.
 *
 * @param array $args {
 *     @type string $content The content of the activity update.
 *     @type int $user_id Optional. Defaults to the logged-in user.
 * }
 * @return int $activity_id The activity id
 */
function bp_activity_post_update($args = '')
{
    $r = wp_parse_args($args, array('content' => false, 'user_id' => bp_loggedin_user_id()));
    if (empty($r['content']) || !strlen(trim($r['content']))) {
        return false;
    }
    if (bp_is_user_inactive($r['user_id'])) {
        return false;
    }
    // Record this on the user's profile
    $activity_content = $r['content'];
    $primary_link = bp_core_get_userlink($r['user_id'], false, true);
    // Now write the values
    $activity_id = bp_activity_add(array('user_id' => $r['user_id'], 'content' => apply_filters('bp_activity_new_update_content', $activity_content), 'primary_link' => apply_filters('bp_activity_new_update_primary_link', $primary_link), 'component' => buddypress()->activity->id, 'type' => 'activity_update'));
    $activity_content = apply_filters('bp_activity_latest_update_content', $r['content'], $activity_content);
    // Add this update to the "latest update" usermeta so it can be fetched anywhere.
    bp_update_user_meta(bp_loggedin_user_id(), 'bp_latest_update', array('id' => $activity_id, 'content' => $activity_content));
    do_action('bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id);
    return $activity_id;
}
开发者ID:eresyyl,项目名称:mk,代码行数:42,代码来源:bp-activity-functions.php

示例6: bp_activity_post_update

/**
 * Post an activity update.
 *
 * @since 1.2.0
 *
 * @uses wp_parse_args()
 * @uses bp_is_user_inactive()
 * @uses bp_core_get_userlink()
 * @uses bp_activity_add()
 * @uses apply_filters() To call the 'bp_activity_new_update_action' hook.
 * @uses apply_filters() To call the 'bp_activity_new_update_content' hook.
 * @uses apply_filters() To call the 'bp_activity_new_update_primary_link' hook.
 * @uses bp_update_user_meta()
 * @uses wp_filter_kses()
 * @uses do_action() To call the 'bp_activity_posted_update' hook.
 *
 * @param array|string $args {
 *     @type string $content The content of the activity update.
 *     @type int    $user_id Optional. Defaults to the logged-in user.
 * }
 * @return int $activity_id The activity id.
 */
function bp_activity_post_update($args = '')
{
    $r = wp_parse_args($args, array('content' => false, 'user_id' => bp_loggedin_user_id()));
    if (empty($r['content']) || !strlen(trim($r['content']))) {
        return false;
    }
    if (bp_is_user_inactive($r['user_id'])) {
        return false;
    }
    // Record this on the user's profile.
    $activity_content = $r['content'];
    $primary_link = bp_core_get_userlink($r['user_id'], false, true);
    /**
     * Filters the new activity content for current activity item.
     *
     * @since 1.2.0
     *
     * @param string $activity_content Activity content posted by user.
     */
    $add_content = apply_filters('bp_activity_new_update_content', $activity_content);
    /**
     * Filters the activity primary link for current activity item.
     *
     * @since 1.2.0
     *
     * @param string $primary_link Link to the profile for the user who posted the activity.
     */
    $add_primary_link = apply_filters('bp_activity_new_update_primary_link', $primary_link);
    // Now write the values.
    $activity_id = bp_activity_add(array('user_id' => $r['user_id'], 'content' => $add_content, 'primary_link' => $add_primary_link, 'component' => buddypress()->activity->id, 'type' => 'activity_update'));
    /**
     * Filters the latest update content for the activity item.
     *
     * @since 1.6.0
     *
     * @param string $r                Content of the activity update.
     * @param string $activity_content Content of the activity update.
     */
    $activity_content = apply_filters('bp_activity_latest_update_content', $r['content'], $activity_content);
    // Add this update to the "latest update" usermeta so it can be fetched anywhere.
    bp_update_user_meta(bp_loggedin_user_id(), 'bp_latest_update', array('id' => $activity_id, 'content' => $activity_content));
    /**
     * Fires at the end of an activity post update, before returning the updated activity item ID.
     *
     * @since 1.2.0
     *
     * @param string $content     Content of the activity post update.
     * @param int    $user_id     ID of the user posting the activity update.
     * @param int    $activity_id ID of the activity item being updated.
     */
    do_action('bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id);
    return $activity_id;
}
开发者ID:humanmade,项目名称:BuddyPress,代码行数:75,代码来源:bp-activity-functions.php

示例7: bp_forums_insert_post

function bp_forums_insert_post($args = '')
{
    global $bp;
    do_action('bbpress_init');
    $defaults = array('post_id' => false, 'topic_id' => false, 'post_text' => '', 'post_time' => bp_core_current_time(), 'poster_id' => bp_loggedin_user_id(), 'poster_ip' => $_SERVER['REMOTE_ADDR'], 'post_status' => 0, 'post_position' => false);
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    if (!($post = bp_forums_get_post($post_id))) {
        $post_id = false;
    }
    if (!isset($topic_id)) {
        $topic_id = $post->topic_id;
    }
    if (empty($post_text)) {
        $post_text = $post->post_text;
    }
    if (!isset($post_time)) {
        $post_time = $post->post_time;
    }
    if (!isset($post_position)) {
        $post_position = $post->post_position;
    }
    if (empty($poster_id)) {
        return false;
    }
    if (bp_is_user_inactive(bp_loggedin_user_id())) {
        return false;
    }
    $post_id = bb_insert_post(array('post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes(trim($post_text)), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position));
    if (!empty($post_id)) {
        do_action('bp_forums_new_post', $post_id);
    }
    return $post_id;
}
开发者ID:hscale,项目名称:webento,代码行数:34,代码来源:bp-forums-functions.php

示例8: bp_get_activity_latest_update

/**
 * Return the activity latest update link.
 *
 * @since BuddyPress (1.2.0)
 *
 * @uses bp_is_user_inactive()
 * @uses bp_core_is_user_deleted()
 * @uses bp_get_user_meta()
 * @uses apply_filters() To call the 'bp_get_activity_latest_update_excerpt' hook
 * @uses bp_create_excerpt()
 * @uses bp_get_root_domain()
 * @uses bp_get_activity_root_slug()
 * @uses apply_filters() To call the 'bp_get_activity_latest_update' hook
 *
 * @param int $user_id If empty, will fall back on displayed user.
 * @return string|bool $latest_update The activity latest update link.
 *         False on failure
 */
function bp_get_activity_latest_update($user_id = 0)
{
    if (empty($user_id)) {
        $user_id = bp_displayed_user_id();
    }
    if (bp_is_user_inactive($user_id)) {
        return false;
    }
    if (!($update = bp_get_user_meta($user_id, 'bp_latest_update', true))) {
        return false;
    }
    /**
     * Filters the latest update excerpt.
     *
     * @since BuddyPress (1.2.10)
     *
     * @param string $value The excerpt for the latest update.
     */
    $latest_update = apply_filters('bp_get_activity_latest_update_excerpt', trim(strip_tags(bp_create_excerpt($update['content'], 358))));
    $latest_update = sprintf('%s <a href="%s">%s</a>', $latest_update, esc_url_raw(bp_activity_get_permalink($update['id'])), esc_attr__('View', 'buddypress'));
    /**
     * Filters the latest update excerpt with view link appended to the end.
     *
     * @since BuddyPress (1.2.0)
     *
     * @param string $latest_update The latest update with "view" link appended to it.
     */
    return apply_filters('bp_get_activity_latest_update', $latest_update);
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:47,代码来源:bp-activity-template.php

示例9: bp_get_activity_latest_update

/**
 * Return the activity latest update link.
 *
 * @since BuddyPress (1.2)
 *
 * @uses bp_is_user_inactive()
 * @uses bp_core_is_user_deleted()
 * @uses bp_get_user_meta()
 * @uses apply_filters() To call the 'bp_get_activity_latest_update_excerpt' hook
 * @uses bp_create_excerpt()
 * @uses bp_get_root_domain()
 * @uses bp_get_activity_root_slug()
 * @uses apply_filters() To call the 'bp_get_activity_latest_update' hook
 *
 * @param int $user_id If empty, will fall back on displayed user.
 * @return string|bool $latest_update The activity latest update link.
 *         False on failure
 */
function bp_get_activity_latest_update($user_id = 0)
{
    if (empty($user_id)) {
        $user_id = bp_displayed_user_id();
    }
    if (bp_is_user_inactive($user_id)) {
        return false;
    }
    if (!($update = bp_get_user_meta($user_id, 'bp_latest_update', true))) {
        return false;
    }
    $latest_update = apply_filters('bp_get_activity_latest_update_excerpt', trim(strip_tags(bp_create_excerpt($update['content'], 358))));
    $latest_update .= ' <a href="' . bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $update['id'] . '/"> ' . __('View', 'buddypress') . '</a>';
    return apply_filters('bp_get_activity_latest_update', $latest_update);
}
开发者ID:eresyyl,项目名称:mk,代码行数:33,代码来源:bp-activity-template.php

示例10: 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

示例11: bp_activity_post_update

/**
 * Post an activity update
 *
 * @since BuddyPress (1.2)
 *
 * @param array $args See docs for $defaults for details
 *
 * @global object $bp BuddyPress global settings
 * @uses wp_parse_args()
 * @uses bp_is_user_inactive()
 * @uses bp_core_get_userlink()
 * @uses bp_activity_add()
 * @uses apply_filters() To call the 'bp_activity_new_update_action' hook
 * @uses apply_filters() To call the 'bp_activity_new_update_content' hook
 * @uses apply_filters() To call the 'bp_activity_new_update_primary_link' hook
 * @uses bp_update_user_meta()
 * @uses wp_filter_kses()
 * @uses do_action() To call the 'bp_activity_posted_update' hook
 *
 * @return int $activity_id The activity id
 */
function bp_activity_post_update($args = '')
{
    global $bp;
    $defaults = array('content' => false, 'user_id' => bp_loggedin_user_id());
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    if (empty($content) || !strlen(trim($content))) {
        return false;
    }
    if (bp_is_user_inactive($user_id)) {
        return false;
    }
    // Record this on the user's profile
    $from_user_link = bp_core_get_userlink($user_id);
    $activity_action = sprintf(__('%s posted an update', 'buddypress'), $from_user_link);
    $activity_content = $content;
    $primary_link = bp_core_get_userlink($user_id, false, true);
    // Now write the values
    $activity_id = bp_activity_add(array('user_id' => $user_id, 'action' => apply_filters('bp_activity_new_update_action', $activity_action), 'content' => apply_filters('bp_activity_new_update_content', $activity_content), 'primary_link' => apply_filters('bp_activity_new_update_primary_link', $primary_link), 'component' => $bp->activity->id, 'type' => 'activity_update'));
    $activity_content = apply_filters('bp_activity_latest_update_content', $content);
    // Add this update to the "latest update" usermeta so it can be fetched anywhere.
    bp_update_user_meta(bp_loggedin_user_id(), 'bp_latest_update', array('id' => $activity_id, 'content' => $content));
    do_action('bp_activity_posted_update', $content, $user_id, $activity_id);
    return $activity_id;
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:46,代码来源:bp-activity-functions.php

示例12: bp_core_record_activity

/**
 * Record user activity to the database. 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.
 *
 * @package BuddyPress Core
 * @global $userdata WordPress user data for the current logged in user.
 * @uses bp_update_user_meta() BP function to update user metadata in the usermeta table.
 */
function bp_core_record_activity()
{
    global $bp;
    if (!is_user_logged_in()) {
        return false;
    }
    $user_id = bp_loggedin_user_id();
    if (bp_is_user_inactive($user_id)) {
        return false;
    }
    $activity = bp_get_user_meta($user_id, 'last_activity', true);
    if (!is_numeric($activity)) {
        $activity = strtotime($activity);
    }
    // Get current time
    $current_time = bp_core_current_time();
    if (empty($activity) || strtotime($current_time) >= strtotime('+5 minutes', $activity)) {
        bp_update_user_meta($user_id, 'last_activity', $current_time);
    }
}
开发者ID:newington,项目名称:buddypress,代码行数:29,代码来源:bp-core-functions.php


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