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


PHP BP_XProfile_ProfileData::get_all_for_user方法代码示例

本文整理汇总了PHP中BP_XProfile_ProfileData::get_all_for_user方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_XProfile_ProfileData::get_all_for_user方法的具体用法?PHP BP_XProfile_ProfileData::get_all_for_user怎么用?PHP BP_XProfile_ProfileData::get_all_for_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BP_XProfile_ProfileData的用法示例。


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

示例1: the_invite

 function the_invite()
 {
     global $group_id;
     $this->in_the_loop = true;
     $user_id = $this->next_invite();
     $this->invite = new stdClass();
     $this->invite->user = $this->invite_data[$user_id];
     // This method previously populated the user object with
     // BP_Core_User. We manually configure BP_Core_User data for
     // backward compatibility.
     if (bp_is_active('xprofile')) {
         $this->invite->user->profile_data = BP_XProfile_ProfileData::get_all_for_user($user_id);
     }
     $this->invite->user->avatar = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'full', 'alt' => sprintf(__('Avatar of %s', 'buddypress'), $this->invite->user->fullname)));
     $this->invite->user->avatar_thumb = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf(__('Avatar of %s', 'buddypress'), $this->invite->user->fullname)));
     $this->invite->user->avatar_mini = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf(__('Avatar of %s', 'buddypress'), $this->invite->user->fullname), 'width' => 30, 'height' => 30));
     $this->invite->user->email = $this->invite->user->user_email;
     $this->invite->user->user_url = bp_core_get_user_domain($user_id, $this->invite->user->user_nicename, $this->invite->user->user_login);
     $this->invite->user->user_link = "<a href='{$this->invite->user->user_url}' title='{$this->invite->user->fullname}'>{$this->invite->user->fullname}</a>";
     $this->invite->user->last_active = bp_core_get_last_activity($this->invite->user->last_activity, __('active %s', 'buddypress'));
     if (bp_is_active('groups')) {
         $total_groups = BP_Groups_Member::total_group_count($user_id);
         $this->invite->user->total_groups = sprintf(_n('%d group', '%d groups', $total_groups, 'buddypress'), $total_groups);
     }
     if (bp_is_active('friends')) {
         $this->invite->user->total_friends = BP_Friends_Friendship::total_friend_count($user_id);
     }
     if (bp_is_active('friends')) {
         $this->invite->user->total_friends = BP_Friends_Friendship::total_friend_count($user_id);
     }
     $this->invite->user->total_blogs = null;
     $this->invite->group_id = $group_id;
     // Globaled in bp_group_has_invites()
     if (0 == $this->current_invite) {
         // loop has just started
         do_action('loop_start');
     }
 }
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:38,代码来源:bp-groups-template.php

示例2: get_profile_data

 /**
  * Fetch xprofile data for the current user.
  *
  * @see BP_XProfile_ProfileData::get_all_for_user() for description of
  *      return value.
  *
  * @return array See {@link BP_XProfile_Profile_Data::get_all_for_user()}.
  */
 public function get_profile_data()
 {
     return BP_XProfile_ProfileData::get_all_for_user($this->id);
 }
开发者ID:kosir,项目名称:thatcamp-org,代码行数:12,代码来源:class-bp-core-user.php

示例3: bp_get_member_profile_data

/**
 * Get a piece of user profile data.
 *
 * When used in a bp_has_members() loop, this function will attempt
 * to fetch profile data cached in the template global. It is also safe
 * to use outside of the loop.
 *
 * @param array|string $args {
 *     Array of config parameters.
 *     @type string $field   Name of the profile field.
 *     @type int    $user_id ID of the user whose data is being fetched.
 *                           Defaults to the current member in the loop, or if not
 *                           present, to the currently displayed user.
 * }
 * @return string|bool Profile data if found, otherwise false.
 */
function bp_get_member_profile_data($args = '')
{
    global $members_template;
    if (!bp_is_active('xprofile')) {
        return false;
    }
    // Declare local variables.
    $data = false;
    // Guess at default $user_id.
    $default_user_id = 0;
    if (!empty($members_template->member->id)) {
        $default_user_id = $members_template->member->id;
    } elseif (bp_displayed_user_id()) {
        $default_user_id = bp_displayed_user_id();
    }
    $defaults = array('field' => false, 'user_id' => $default_user_id);
    $r = wp_parse_args($args, $defaults);
    // If we're in a members loop, get the data from the global.
    if (!empty($members_template->member->profile_data)) {
        $profile_data = $members_template->member->profile_data;
    }
    // Otherwise query for the data.
    if (empty($profile_data) && method_exists('BP_XProfile_ProfileData', 'get_all_for_user')) {
        $profile_data = BP_XProfile_ProfileData::get_all_for_user($r['user_id']);
    }
    // If we're in the members loop, but the profile data has not
    // been loaded into the global, cache it there for later use.
    if (!empty($members_template->member) && empty($members_template->member->profile_data)) {
        $members_template->member->profile_data = $profile_data;
    }
    // Get the data for the specific field requested.
    if (!empty($profile_data) && !empty($profile_data[$r['field']]['field_type']) && !empty($profile_data[$r['field']]['field_data'])) {
        $data = xprofile_format_profile_field($profile_data[$r['field']]['field_type'], $profile_data[$r['field']]['field_data']);
    }
    /**
     * Filters resulting piece of member profile data.
     *
     * @since 1.2.0
     *
     * @param string|bool $data Profile data if found, otherwise false.
     */
    return apply_filters('bp_get_member_profile_data', $data);
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:59,代码来源:bp-members-template.php

示例4: test_get_all_for_user_cached

 /**
  * @group get_all_for_user
  */
 public function test_get_all_for_user_cached()
 {
     $u = $this->factory->user->create();
     $g1 = $this->factory->xprofile_group->create();
     $g2 = $this->factory->xprofile_group->create();
     $f1 = $this->factory->xprofile_field->create(array('type' => 'textbox', 'field_group_id' => $g1));
     $f2 = $this->factory->xprofile_field->create(array('type' => 'radio', 'field_group_id' => $g2));
     $time = bp_core_current_time();
     $g0 = new BP_XProfile_Group(1);
     $f0 = new BP_XProfile_Field(1);
     $d0 = new BP_XProfile_ProfileData(1, $u);
     $d1 = new stdClass();
     $d1->user_id = $u;
     $d1->field_id = $f1;
     $d1->value = 'foo';
     $d1->last_updated = $time;
     $d1->id = 1;
     $d2 = new stdClass();
     $d2->user_id = $u;
     $d2->field_id = $f2;
     $d2->value = 'bar';
     $d2->last_updated = $time;
     $d2->id = 2;
     wp_cache_set("{$u}:{$f1}", $d1, 'bp_xprofile_data');
     wp_cache_set("{$u}:{$f2}", $d2, 'bp_xprofile_data');
     $u_obj = new WP_User($u);
     $g1_obj = new BP_XProfile_Group($g1);
     $g2_obj = new BP_XProfile_Group($g2);
     $f1_obj = new BP_XProfile_Field($f1);
     $f2_obj = new BP_XProfile_Field($f2);
     $expected = array('user_login' => $u_obj->user_login, 'user_nicename' => $u_obj->user_nicename, 'user_email' => $u_obj->user_email, $f0->name => array('field_group_id' => $g0->id, 'field_group_name' => $g0->name, 'field_id' => $f0->id, 'field_type' => $f0->type, 'field_data' => $d0->value), $f1_obj->name => array('field_group_id' => $g1, 'field_group_name' => $g1_obj->name, 'field_id' => $f1, 'field_type' => $f1_obj->type, 'field_data' => $d1->value), $f2_obj->name => array('field_group_id' => $g2, 'field_group_name' => $g2_obj->name, 'field_id' => $f2, 'field_type' => $f2_obj->type, 'field_data' => $d2->value));
     $this->assertEquals($expected, BP_XProfile_ProfileData::get_all_for_user($u));
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:36,代码来源:class-bp-xprofile-profiledata.php

示例5: bp_get_member_profile_data

function bp_get_member_profile_data($args = '')
{
    global $bp, $members_template;
    if (!bp_is_active('xprofile')) {
        return false;
    }
    // Declare local variables
    $data = false;
    $user_id = 0;
    // Guess at default $user_id
    if (!empty($members_template->member->id)) {
        $user_id = $members_template->member->id;
    } elseif (!empty($bp->displayed_user->id)) {
        $user_id = $bp->displayed_user->id;
    }
    $defaults = array('field' => false, 'user_id' => $user_id);
    $r = nxt_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // Populate the user if it hasn't been already.
    if (empty($members_template->member->profile_data) && method_exists('BP_XProfile_ProfileData', 'get_all_for_user')) {
        $members_template->member->profile_data = BP_XProfile_ProfileData::get_all_for_user($user_id);
    }
    // Get the field data if there is data to get
    if (!empty($members_template->member->profile_data)) {
        $data = xprofile_format_profile_field($members_template->member->profile_data[$field]['field_type'], $members_template->member->profile_data[$field]['field_data']);
    }
    return apply_filters('bp_get_member_profile_data', $data);
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:28,代码来源:bp-members-template.php

示例6: generate_data


//.........这里部分代码省略.........
                 $headers[] = $field;
                 #echo '<script>console.log("Echoing header cell: '.$field.'")</script>';
             }
         }
     }
     // no more buffering while spitting back the export data ##
     ob_end_flush();
     // get the value in bytes allocated for Memory via php.ini ##
     // @link http://wordpress.org/support/topic/how-to-exporting-a-lot-of-data-out-of-memory-issue?replies=2
     $memory_limit = $this->return_bytes(ini_get('memory_limit')) * 0.75;
     // we need to disable caching while exporting because we export so much data that it could blow the memory cache
     // if we can't override the cache here, we'll have to clear it later...
     if (function_exists('override_function')) {
         override_function('wp_cache_add', '$key, $data, $group="", $expire=0', '');
         override_function('wp_cache_set', '$key, $data, $group="", $expire=0', '');
         override_function('wp_cache_replace', '$key, $data, $group="", $expire=0', '');
         override_function('wp_cache_add_non_persistent_groups', '$key, $data, $group="", $expire=0', '');
     } elseif (function_exists('runkit_function_redefine')) {
         runkit_function_redefine('wp_cache_add', '$key, $data, $group="", $expire=0', '');
         runkit_function_redefine('wp_cache_set', '$key, $data, $group="", $expire=0', '');
         runkit_function_redefine('wp_cache_replace', '$key, $data, $group="", $expire=0', '');
         runkit_function_redefine('wp_cache_add_non_persistent_groups', '$key, $data, $group="", $expire=0', '');
     }
     // open doc wrapper.. ##
     echo $doc_begin;
     // echo headers ##
     echo $pre . implode($seperator, $headers) . $breaker;
     // build row values for each user ##
     foreach ($users as $user) {
         // check if we're hitting any Memory limits, if so flush them out ##
         // per http://wordpress.org/support/topic/how-to-exporting-a-lot-of-data-out-of-memory-issue?replies=2
         if (memory_get_usage(true) > $memory_limit) {
             wp_cache_flush();
         }
         // open up a new empty array ##
         $data = array();
         // BP loaded ? ##
         if (function_exists('bp_is_active')) {
             $bp_data = BP_XProfile_ProfileData::get_all_for_user($user->ID);
         }
         // 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)) {
                 $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 = $this->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['q_eud_role']) && $_POST['q_eud_role'] != '' && $field == 'role') {
                 // add "Role" as $value ##
                 $value = $user->roles[0] ? $user->roles[0] : '';
                 // empty value if no role found - note: we only take the first role assigned to the user ##
                 // user data or usermeta ##
             } else {
                 $value = isset($user->{$field}) ? $user->{$field} : '';
                 #$value = is_array( $value ) ? serialize( $value ) : $value; // maybe serialize the value ##
                 $value = is_array($value) ? implode(", ", $value) : $value;
                 // maybe serialize the value - suggested by @nicmare ##
             }
             // correct program value to Program Name ##
             if ($field == 'member_of_club') {
                 $value = get_the_title($value);
             }
             if ($is_csv) {
                 $data[] = '"' . str_replace('"', '""', $value) . '"';
             } else {
                 $data[] = $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:grexican,项目名称:export-user-data,代码行数:101,代码来源:export-user-data.php

示例7: the_invite

 /**
  * Sets up the invite to show.
  *
  * @since 1.1.0
  */
 public function the_invite()
 {
     global $group_id;
     $this->in_the_loop = true;
     $user_id = $this->next_invite();
     $this->invite = new stdClass();
     $this->invite->user = $this->invite_data[$user_id];
     // This method previously populated the user object with
     // BP_Core_User. We manually configure BP_Core_User data for
     // backward compatibility.
     if (bp_is_active('xprofile')) {
         $this->invite->user->profile_data = BP_XProfile_ProfileData::get_all_for_user($user_id);
     }
     $this->invite->user->avatar = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'full', 'alt' => sprintf(__('Profile photo of %s', 'buddypress'), $this->invite->user->fullname)));
     $this->invite->user->avatar_thumb = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf(__('Profile photo of %s', 'buddypress'), $this->invite->user->fullname)));
     $this->invite->user->avatar_mini = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf(__('Profile photo of %s', 'buddypress'), $this->invite->user->fullname), 'width' => 30, 'height' => 30));
     $this->invite->user->email = $this->invite->user->user_email;
     $this->invite->user->user_url = bp_core_get_user_domain($user_id, $this->invite->user->user_nicename, $this->invite->user->user_login);
     $this->invite->user->user_link = "<a href='{$this->invite->user->user_url}' title='{$this->invite->user->fullname}'>{$this->invite->user->fullname}</a>";
     $this->invite->user->last_active = bp_core_get_last_activity($this->invite->user->last_activity, __('active %s', 'buddypress'));
     if (bp_is_active('groups')) {
         $total_groups = BP_Groups_Member::total_group_count($user_id);
         $this->invite->user->total_groups = sprintf(_n('%d group', '%d groups', $total_groups, 'buddypress'), $total_groups);
     }
     if (bp_is_active('friends')) {
         $this->invite->user->total_friends = BP_Friends_Friendship::total_friend_count($user_id);
     }
     $this->invite->user->total_blogs = null;
     // Global'ed in bp_group_has_invites()
     $this->invite->group_id = $group_id;
     // loop has just started
     if (0 == $this->current_invite) {
         /**
          * Fires if the current invite item is the first in the loop.
          *
          * @since 1.1.0
          * @since 2.3.0 `$this` parameter added.
          * @since 2.7.0 Action renamed from `loop_start`.
          *
          * @param BP_Groups_Invite_Template $this Instance of the current Invites template.
          */
         do_action('group_invitation_loop_start', $this);
     }
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:49,代码来源:class-bp-groups-invite-template.php

示例8: setup_user_sm_fields

 /**
  * Loads the displayed user's SM fields
  */
 function setup_user_sm_fields()
 {
     global $bp;
     $this->load_fieldmeta();
     $this->setup_smp_site_data();
     // Get all of the user's xprofile fields
     $user_xprofile_fields = BP_XProfile_ProfileData::get_all_for_user(bp_displayed_user_id());
     // Go through all the fields, pick out the ones with bp_smp_data, and store their ids and values
     // for us on display
     foreach ($user_xprofile_fields as $field_name => $xprofile_field) {
         if (!isset($xprofile_field['field_id'])) {
             continue;
         }
         $smp_field_id = $xprofile_field['field_id'];
         if ($this->is_smp_field($smp_field_id)) {
             $field_bp_smp_data = bp_xprofile_get_meta($smp_field_id, 'field', 'bp_smp_data');
             if (isset($field_bp_smp_data['site']) && $field_bp_smp_data['site'] != '') {
                 $smp_field_value = xprofile_get_field_data($smp_field_id, bp_displayed_user_id());
                 $site_id = strtolower($field_name);
                 // Get the callback function for the field
                 $callback = isset($this->smp_site_data->sites[$site_id]['callback']) ? $this->smp_site_data->sites[$site_id]['callback'] : '';
                 // If the user hasn't supplied a URL pattern, check to make sure one hasn't been defined in the defaults
                 // If one has, pass it to the callback function
                 if (!isset($this->fieldmeta[$smp_field_id]['url_pattern']) || $this->fieldmeta[$smp_field_id]['url_pattern'] != '') {
                     if (isset($this->smp_site_data->sites[$site_id]['url_pattern']) && $this->smp_site_data->sites[$site_id]['url_pattern'] != '') {
                         $url_pattern = $this->smp_site_data->sites[$site_id]['url_pattern'];
                     } else {
                         $url_pattern = $this->fieldmeta[$smp_field_id]['url_pattern'];
                     }
                 }
                 // Run the callback
                 $smp_data = call_user_func_array($callback, array($smp_field_value, $url_pattern));
                 $smp_data = apply_filters("bp_smp_" . $callback[1], $smp_data, $smp_field_value, $this->fieldmeta[$smp_field_id]);
                 $smp_data['html'] = $this->create_field_html($smp_data);
                 $this->user_sm_fields[] = $smp_data;
             }
         }
     }
 }
开发者ID:rjbaniel,项目名称:bp-social-media-profiles,代码行数:42,代码来源:bp-social-media-profiles.php

示例9: generate_data


//.........这里部分代码省略.........
     $memory_limit = $this->return_bytes(ini_get('memory_limit')) * 0.75;
     // we need to disable caching while exporting because we export so much data that it could blow the memory cache
     // if we can't override the cache here, we'll have to clear it later...
     if (function_exists('override_function')) {
         override_function('wp_cache_add', '$key, $data, $group="", $expire=0', '');
         override_function('wp_cache_set', '$key, $data, $group="", $expire=0', '');
         override_function('wp_cache_replace', '$key, $data, $group="", $expire=0', '');
         override_function('wp_cache_add_non_persistent_groups', '$key, $data, $group="", $expire=0', '');
     } elseif (function_exists('runkit_function_redefine')) {
         runkit_function_redefine('wp_cache_add', '$key, $data, $group="", $expire=0', '');
         runkit_function_redefine('wp_cache_set', '$key, $data, $group="", $expire=0', '');
         runkit_function_redefine('wp_cache_replace', '$key, $data, $group="", $expire=0', '');
         runkit_function_redefine('wp_cache_add_non_persistent_groups', '$key, $data, $group="", $expire=0', '');
     }
     // open doc wrapper.. ##
     echo $doc_begin;
     // echo headers ##
     echo $pre . implode($seperator, $headers) . $breaker;
     #wp_die( self::pr( $users ) );
     // build row values for each user ##
     foreach ($users as $user) {
         #wp_die( self::pr( $user ) );
         // check if we're hitting any Memory limits, if so flush them out ##
         // per http://wordpress.org/support/topic/how-to-exporting-a-lot-of-data-out-of-memory-issue?replies=2
         if (memory_get_usage(true) > $memory_limit) {
             wp_cache_flush();
         }
         // open up a new empty array ##
         $data = array();
         #wp_die( self::pr( $GLOBALS['bp'] ) );
         // BP loaded ? ##
         if (function_exists('bp_is_active') && bp_is_active('xprofile')) {
             // grab all user data ##
             $bp_data = BP_XProfile_ProfileData::get_all_for_user($user->ID);
         }
         // single query method - get all user_meta data ##
         $get_user_meta = (array) get_user_meta($user->ID);
         #wp_die( self::pr( $get_user_meta ) );
         // Filter out empty meta data ##
         #$get_user_meta = array_filter( array_map( function( $a ) {
         #    return $a[0];
         #}, $get_user_meta ) );
         // 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);
                     }
                 }
开发者ID:adnandot,项目名称:intenseburn,代码行数:67,代码来源:export-user-data.php

示例10: bp_get_member_profile_data

	function bp_get_member_profile_data( $args = '' ) {
		global $members_template;

		if ( !function_exists( 'xprofile_install' ) )
			return false;

		$defaults = array(
			'field' => false, // Field name
		);

		$r = wp_parse_args( $args, $defaults );
		extract( $r, EXTR_SKIP );

		// Populate the user if it hasn't been already.
		if ( empty( $members_template->member->profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ) )
			$members_template->member->profile_data = BP_XProfile_ProfileData::get_all_for_user( $members_template->member->id );

		$data = xprofile_format_profile_field( $members_template->member->profile_data[$field]['field_type'], $members_template->member->profile_data[$field]['field_data'] );

		return apply_filters( 'bp_get_member_profile_data', $data );
	}
开发者ID:n-sane,项目名称:zaroka,代码行数:21,代码来源:bp-core-templatetags.php


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