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


PHP bp_get_user_meta_key函数代码示例

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


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

示例1: test_bp_user_query_sort_by_popular

 public function test_bp_user_query_sort_by_popular()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $u3 = $this->factory->user->create();
     $u4 = $this->factory->user->create();
     bp_update_user_meta($u1, bp_get_user_meta_key('total_friend_count'), '5');
     bp_update_user_meta($u2, bp_get_user_meta_key('total_friend_count'), '90');
     bp_update_user_meta($u3, bp_get_user_meta_key('total_friend_count'), '101');
     bp_update_user_meta($u4, bp_get_user_meta_key('total_friend_count'), '3002');
     $q = new BP_User_Query(array('type' => 'popular'));
     $users = is_array($q->results) ? array_values($q->results) : array();
     $user_ids = wp_parse_id_list(wp_list_pluck($users, 'ID'));
     $expected = array($u4, $u3, $u2, $u1);
     $this->assertEquals($expected, $user_ids);
 }
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:16,代码来源:class-bp-user-query.php

示例2: bp_core_screen_notification_settings

/** Notifications *************************************************************/
function bp_core_screen_notification_settings()
{
    global $bp;
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    if (isset($_POST['submit'])) {
        check_admin_referer('bp_settings_notifications');
        if (isset($_POST['notifications'])) {
            foreach ((array) $_POST['notifications'] as $key => $value) {
                if ($meta_key = bp_get_user_meta_key($key)) {
                    bp_update_user_meta((int) $bp->displayed_user->id, $meta_key, $value);
                }
            }
        }
        bp_core_add_message(__('Changes saved.', 'buddypress'), 'success');
        do_action('bp_core_notification_settings_after_save');
    }
    bp_core_load_template(apply_filters('bp_core_screen_notification_settings', 'members/single/settings/notifications'));
}
开发者ID:hornetalcala,项目名称:trunk,代码行数:22,代码来源:bp-settings-actions.php

示例3: bp_delete_user_meta

/**
 * Delete a piece of usermeta.
 *
 * This is a wrapper for delete_user_meta() that allows for easy use of
 * bp_get_user_meta_key(), thereby increasing compatibility with non-standard
 * BP setups.
 *
 * @since BuddyPress (1.5.0)
 *
 * @see delete_user_meta() For complete details about parameters and return values.
 * @uses bp_get_user_meta_key() For a filterable version of the meta key.
 *
 * @param int $user_id The ID of the user whose meta you're deleting.
 * @param string $key The meta key to delete.
 * @param mixed $value Optional. Metadata value.
 * @return bool False for failure. True for success.
 */
function bp_delete_user_meta($user_id, $key, $value = '')
{
    return delete_user_meta($user_id, bp_get_user_meta_key($key), $value);
}
开发者ID:antares-ff,项目名称:ANTARES-Test,代码行数:21,代码来源:bp-core-functions.php

示例4: populate_extras

 /**
  * Perform a database query to populate any extra metadata we might need.
  *
  * Different components will hook into the 'bp_user_query_populate_extras'
  * action to loop in the things they want.
  *
  * @since 1.7.0
  *
  * @global WPDB $wpdb Global WordPress database access object.
  */
 public function populate_extras()
 {
     global $wpdb;
     // Bail if no users.
     if (empty($this->user_ids) || empty($this->results)) {
         return;
     }
     // Bail if the populate_extras flag is set to false
     // In the case of the 'popular' sort type, we force
     // populate_extras to true, because we need the friend counts.
     if ('popular' == $this->query_vars['type']) {
         $this->query_vars['populate_extras'] = 1;
     }
     if (!(bool) $this->query_vars['populate_extras']) {
         return;
     }
     // Turn user ID's into a query-usable, comma separated value.
     $user_ids_sql = implode(',', wp_parse_id_list($this->user_ids));
     /**
      * Allows users to independently populate custom extras.
      *
      * Note that anything you add here should query using $user_ids_sql, to
      * avoid running multiple queries per user in the loop.
      *
      * Two BuddyPress components currently do this:
      * - XProfile: To override display names.
      * - Friends:  To set whether or not a user is the current users friend.
      *
      * @see bp_xprofile_filter_user_query_populate_extras()
      * @see bp_friends_filter_user_query_populate_extras()
      *
      * @since 1.7.0
      *
      * @param BP_User_Query $this         Current BP_User_Query instance.
      * @param string        $user_ids_sql Comma-separated string of user IDs.
      */
     do_action_ref_array('bp_user_query_populate_extras', array($this, $user_ids_sql));
     // Fetch last_active data from the activity table.
     $last_activities = BP_Core_User::get_last_activity($this->user_ids);
     // Set a last_activity value for each user, even if it's empty.
     foreach ($this->results as $user_id => $user) {
         $user_last_activity = isset($last_activities[$user_id]) ? $last_activities[$user_id]['date_recorded'] : '';
         $this->results[$user_id]->last_activity = $user_last_activity;
     }
     // Fetch usermeta data
     // We want the three following pieces of info from usermeta:
     // - friend count
     // - latest update.
     $total_friend_count_key = bp_get_user_meta_key('total_friend_count');
     $bp_latest_update_key = bp_get_user_meta_key('bp_latest_update');
     // Total_friend_count must be set for each user, even if its
     // value is 0.
     foreach ($this->results as $uindex => $user) {
         $this->results[$uindex]->total_friend_count = 0;
     }
     // Create, prepare, and run the separate usermeta query.
     $user_metas = $wpdb->get_results($wpdb->prepare("SELECT user_id, meta_key, meta_value FROM {$wpdb->usermeta} WHERE meta_key IN (%s,%s) AND user_id IN ({$user_ids_sql})", $total_friend_count_key, $bp_latest_update_key));
     // The $members_template global expects the index key to be different
     // from the meta_key in some cases, so we rejig things here.
     foreach ($user_metas as $user_meta) {
         switch ($user_meta->meta_key) {
             case $total_friend_count_key:
                 $key = 'total_friend_count';
                 break;
             case $bp_latest_update_key:
                 $key = 'latest_update';
                 break;
         }
         if (isset($this->results[$user_meta->user_id])) {
             $this->results[$user_meta->user_id]->{$key} = $user_meta->meta_value;
         }
     }
     // When meta_key or meta_value have been passed to the query,
     // fetch the resulting values for use in the template functions.
     if (!empty($this->query_vars['meta_key'])) {
         $meta_sql = array('select' => "SELECT user_id, meta_key, meta_value", 'from' => "FROM {$wpdb->usermeta}", 'where' => $wpdb->prepare("WHERE meta_key = %s", $this->query_vars['meta_key']));
         if (false !== $this->query_vars['meta_value']) {
             $meta_sql['where'] .= $wpdb->prepare(" AND meta_value = %s", $this->query_vars['meta_value']);
         }
         $metas = $wpdb->get_results("{$meta_sql['select']} {$meta_sql['from']} {$meta_sql['where']}");
         if (!empty($metas)) {
             foreach ($metas as $meta) {
                 if (isset($this->results[$meta->user_id])) {
                     $this->results[$meta->user_id]->meta_key = $meta->meta_key;
                     if (!empty($meta->meta_value)) {
                         $this->results[$meta->user_id]->meta_value = $meta->meta_value;
                     }
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:101,代码来源:class-bp-user-query.php

示例5: get_bulk_last_active

 function get_bulk_last_active($user_ids)
 {
     global $nxtdb, $bp;
     return $nxtdb->get_results($nxtdb->prepare("SELECT meta_value as last_activity, user_id FROM {$nxtdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} ) ORDER BY meta_value DESC", bp_get_user_meta_key('last_activity')));
 }
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:5,代码来源:bp-friends-classes.php

示例6: get_user_extras

 /**
  * Fetch extra user information, such as friend count and last profile update message.
  *
  * Accepts multiple user IDs to fetch data for.
  *
  * @global wpdb $wpdb WordPress database object.
  *
  * @param array $paged_users An array of stdClass containing the users.
  * @param string $user_ids The user ids to select information about.
  * @param string $type The type of fields we wish to get.
  * @return mixed False on error, otherwise associative array of results.
  */
 public static function get_user_extras(&$paged_users, &$user_ids, $type = false)
 {
     global $wpdb;
     $bp = buddypress();
     if (empty($user_ids)) {
         return $paged_users;
     }
     // Sanitize user IDs
     $user_ids = implode(',', wp_parse_id_list($user_ids));
     // Fetch the user's full name
     if (bp_is_active('xprofile') && 'alphabetical' != $type) {
         $names = $wpdb->get_results($wpdb->prepare("SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", bp_xprofile_fullname_field_name()));
         for ($i = 0, $count = count($paged_users); $i < $count; ++$i) {
             foreach ((array) $names as $name) {
                 if ($name->id == $paged_users[$i]->id) {
                     $paged_users[$i]->fullname = $name->fullname;
                 }
             }
         }
     }
     // Fetch the user's total friend count
     if ('popular' != $type) {
         $friend_count = $wpdb->get_results($wpdb->prepare("SELECT user_id as id, meta_value as total_friend_count FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key('total_friend_count')));
         for ($i = 0, $count = count($paged_users); $i < $count; ++$i) {
             foreach ((array) $friend_count as $fcount) {
                 if ($fcount->id == $paged_users[$i]->id) {
                     $paged_users[$i]->total_friend_count = (int) $fcount->total_friend_count;
                 }
             }
         }
     }
     // Fetch whether or not the user is a friend
     if (bp_is_active('friends')) {
         $friend_status = $wpdb->get_results($wpdb->prepare("SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", bp_loggedin_user_id(), bp_loggedin_user_id()));
         for ($i = 0, $count = count($paged_users); $i < $count; ++$i) {
             foreach ((array) $friend_status as $status) {
                 if ($status->initiator_user_id == $paged_users[$i]->id || $status->friend_user_id == $paged_users[$i]->id) {
                     $paged_users[$i]->is_friend = $status->is_confirmed;
                 }
             }
         }
     }
     if ('active' != $type) {
         $user_activity = $wpdb->get_results($wpdb->prepare("SELECT user_id as id, meta_value as last_activity FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key('last_activity')));
         for ($i = 0, $count = count($paged_users); $i < $count; ++$i) {
             foreach ((array) $user_activity as $activity) {
                 if ($activity->id == $paged_users[$i]->id) {
                     $paged_users[$i]->last_activity = $activity->last_activity;
                 }
             }
         }
     }
     // Fetch the user's last_activity
     if ('active' != $type) {
         $user_activity = $wpdb->get_results($wpdb->prepare("SELECT user_id as id, meta_value as last_activity FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key('last_activity')));
         for ($i = 0, $count = count($paged_users); $i < $count; ++$i) {
             foreach ((array) $user_activity as $activity) {
                 if ($activity->id == $paged_users[$i]->id) {
                     $paged_users[$i]->last_activity = $activity->last_activity;
                 }
             }
         }
     }
     // Fetch the user's latest update
     $user_update = $wpdb->get_results($wpdb->prepare("SELECT user_id as id, meta_value as latest_update FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key('bp_latest_update')));
     for ($i = 0, $count = count($paged_users); $i < $count; ++$i) {
         foreach ((array) $user_update as $update) {
             if ($update->id == $paged_users[$i]->id) {
                 $paged_users[$i]->latest_update = $update->latest_update;
             }
         }
     }
     return $paged_users;
 }
开发者ID:kosir,项目名称:thatcamp-org,代码行数:86,代码来源:class-bp-core-user.php

示例7: bp_core_get_active_member_count

/**
 * Returns the total number of members, limited to those members with last_activity
 *
 * @return int The number of active members
 */
function bp_core_get_active_member_count()
{
    global $wpdb;
    if (!($count = get_transient('bp_active_member_count'))) {
        // Avoid a costly join by splitting the lookup
        if (is_multisite()) {
            $sql = "SELECT ID FROM {$wpdb->users} WHERE (user_status != 0 OR deleted != 0 OR user_status != 0)";
        } else {
            $sql = "SELECT ID FROM {$wpdb->users} WHERE user_status != 0";
        }
        $exclude_users = $wpdb->get_col($sql);
        $exclude_users_sql = !empty($exclude_users) ? "AND user_id NOT IN (" . implode(',', wp_parse_id_list($exclude_users)) . ")" : '';
        $count = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(user_id) FROM {$wpdb->usermeta} WHERE meta_key = %s {$exclude_users_sql}", bp_get_user_meta_key('last_activity')));
        set_transient('bp_active_member_count', $count);
    }
    return apply_filters('bp_core_get_active_member_count', $count);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:22,代码来源:bp-members-functions.php

示例8: bp_settings_action_notifications

/**
 * Handles the changing and saving of user notification settings
 *
 * @return If no reason to proceed
 */
function bp_settings_action_notifications()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Bail if not in settings
    if (!bp_is_settings_component() || !bp_is_current_action('notifications')) {
        return false;
    }
    // 404 if there are any additional action variables attached
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    if (isset($_POST['submit'])) {
        check_admin_referer('bp_settings_notifications');
        if (isset($_POST['notifications'])) {
            foreach ((array) $_POST['notifications'] as $key => $value) {
                if ($meta_key = bp_get_user_meta_key($key)) {
                    bp_update_user_meta((int) bp_displayed_user_id(), $meta_key, $value);
                }
            }
        }
        // Switch feedback for super admins
        if (bp_is_my_profile()) {
            bp_core_add_message(__('Your notification settings have been saved.', 'buddypress'), 'success');
        } else {
            bp_core_add_message(__("This user's notification settings have been saved.", 'buddypress'), 'success');
        }
        do_action('bp_core_notification_settings_after_save');
        bp_core_redirect(bp_displayed_user_domain() . bp_get_settings_slug() . '/notifications/');
    }
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:39,代码来源:bp-settings-actions.php

示例9: bp_update_user_meta

 function bp_update_user_meta($user_id, $key, $value, $prev_value = '')
 {
     return update_user_meta($user_id, bp_get_user_meta_key($key), $value, $prev_value);
 }
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:4,代码来源:1.5-abstraction.php

示例10: get_bulk_last_active

 function get_bulk_last_active($user_ids)
 {
     global $wpdb;
     $user_ids = implode(',', wp_parse_id_list($user_ids));
     return $wpdb->get_results($wpdb->prepare("SELECT meta_value as last_activity, user_id FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} ) ORDER BY meta_value DESC", bp_get_user_meta_key('last_activity')));
 }
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:6,代码来源:bp-friends-classes.php


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