本文整理匯總了PHP中BP_XProfile_ProfileData::get_random方法的典型用法代碼示例。如果您正苦於以下問題:PHP BP_XProfile_ProfileData::get_random方法的具體用法?PHP BP_XProfile_ProfileData::get_random怎麽用?PHP BP_XProfile_ProfileData::get_random使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BP_XProfile_ProfileData
的用法示例。
在下文中一共展示了BP_XProfile_ProfileData::get_random方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}