本文整理汇总了PHP中xprofile_format_profile_field函数的典型用法代码示例。如果您正苦于以下问题:PHP xprofile_format_profile_field函数的具体用法?PHP xprofile_format_profile_field怎么用?PHP xprofile_format_profile_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xprofile_format_profile_field函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xprofile_get_random_profile_data
/**
* Fetches a random piece of profile data for the user.
*
* @package BuddyPress Core
* @param int $user_id User ID of the user to get random data for
* @param bool $exclude_fullname Optional; whether or not to exclude the full name field as random data. Defaults to true.
* @global BuddyPress $bp The one true BuddyPress instance
* @global $wpdb WordPress DB access object.
* @global $current_user WordPress global variable containing current logged in user information
* @uses xprofile_format_profile_field() Formats profile field data so it is suitable for display.
* @return string|bool The fetched random data for the user, or false if no data or no match.
*/
function xprofile_get_random_profile_data($user_id, $exclude_fullname = true)
{
$field_data = BP_XProfile_ProfileData::get_random($user_id, $exclude_fullname);
if (empty($field_data)) {
return false;
}
$field_data[0]->value = xprofile_format_profile_field($field_data[0]->type, $field_data[0]->value);
if (empty($field_data[0]->value)) {
return false;
}
/**
* Filters a random piece of profile data for the user.
*
* @since BuddyPress (1.0.0)
*
* @param array $field_data Array holding random profile data.
*/
return apply_filters('xprofile_get_random_profile_data', $field_data);
}
示例2: xprofile_get_random_profile_data
/**
* Fetches a random piece of profile data for the user.
*
* @package BuddyPress Core
* @param $user_id User ID of the user to get random data for
* @param $exclude_fullname whether or not to exclude the full name field as random data.
* @global object $bp Global BuddyPress settings object
* @global $nxtdb NXTClass DB access object.
* @global $current_user NXTClass global variable containing current logged in user information
* @uses xprofile_format_profile_field() Formats profile field data so it is suitable for display.
* @return $field_data The fetched random data for the user.
*/
function xprofile_get_random_profile_data($user_id, $exclude_fullname = true)
{
$field_data = BP_XProfile_ProfileData::get_random($user_id, $exclude_fullname);
if (!$field_data) {
return false;
}
$field_data[0]->value = xprofile_format_profile_field($field_data[0]->type, $field_data[0]->value);
if (!$field_data[0]->value || empty($field_data[0]->value)) {
return false;
}
return apply_filters('xprofile_get_random_profile_data', $field_data);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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 );
}