本文整理汇总了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);
}