本文整理汇总了PHP中BP_XProfile_Field::bp_xprofile_field方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_XProfile_Field::bp_xprofile_field方法的具体用法?PHP BP_XProfile_Field::bp_xprofile_field怎么用?PHP BP_XProfile_Field::bp_xprofile_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BP_XProfile_Field
的用法示例。
在下文中一共展示了BP_XProfile_Field::bp_xprofile_field方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare_buddypress_data
public static function prepare_buddypress_data($user_id, $config, $entry)
{
// required for user to display in the directory
if (function_exists('bp_update_user_last_activity')) {
bp_update_user_last_activity($user_id);
} else {
bp_update_user_meta($user_id, 'last_activity', true);
}
$buddypress_meta = rgars($config, 'meta/buddypress_meta');
if (empty($buddypress_meta)) {
return;
}
self::log_debug(__METHOD__ . '(): starting.');
$form = RGFormsModel::get_form_meta($entry['form_id']);
$buddypress_row = array();
$i = 0;
foreach ($buddypress_meta as $meta_item) {
if (empty($meta_item['meta_name']) || empty($meta_item['meta_value'])) {
continue;
}
$buddypress_row[$i]['field_id'] = $meta_item['meta_name'];
$buddypress_row[$i]['user_id'] = $user_id;
// get GF and BP fields
$gform_field = RGFormsModel::get_field($form, $meta_item['meta_value']);
if (version_compare(BP_VERSION, '1.6', '<')) {
$bp_field = new BP_XProfile_Field();
$bp_field->bp_xprofile_field($meta_item['meta_name']);
} else {
require_once WP_PLUGIN_DIR . '/buddypress/bp-xprofile/bp-xprofile-classes.php';
$bp_field = new BP_XProfile_Field($meta_item['meta_name']);
}
// if bp field is a checkbox AND gf field is a checkbox, get array of input values
$input_type = RGFormsModel::get_input_type($gform_field);
if (in_array($bp_field->type, array('checkbox', 'multiselectbox')) && in_array($input_type, array('checkbox', 'multiselect'))) {
$meta_value = RGFormsModel::get_lead_field_value($entry, $gform_field);
if (!is_array($meta_value)) {
$meta_value = explode(',', $meta_value);
}
$meta_value = self::maybe_get_category_name($gform_field, $meta_value);
$meta_value = array_filter($meta_value, 'GFUser::not_empty');
} else {
if ($bp_field->type == 'datebox' && $gform_field['type'] == 'date') {
if (version_compare(BP_VERSION, '2.1.1', '<')) {
$meta_value = strtotime(self::get_prepared_value($gform_field, $meta_item['meta_value'], $entry));
} else {
$meta_value = self::get_prepared_value($gform_field, $meta_item['meta_value'], $entry) . ' 00:00:00';
}
} else {
$meta_value = self::get_prepared_value($gform_field, $meta_item['meta_value'], $entry);
}
}
self::log_debug(__METHOD__ . "(): Meta item: {$meta_item['meta_name']}. Value: {$meta_value}");
$buddypress_row[$i]['value'] = $meta_value;
$buddypress_row[$i]['last_update'] = date('Y-m-d H:i:s');
$buddypress_row[$i]['field'] = $bp_field;
$i++;
}
GFUserData::insert_buddypress_data($buddypress_row);
self::log_debug(__METHOD__ . '(): finished.');
}
示例2: prepare_buddypress_data
public static function prepare_buddypress_data($user_id, $config, $entry)
{
// required for user to display in the directory
bp_update_user_meta($user_id, 'last_activity', true);
$buddypress_meta = rgars($config, 'meta/buddypress_meta');
if (empty($buddypress_meta)) {
return;
}
$form = RGFormsModel::get_form_meta($entry['form_id']);
$buddypress_row = array();
$i = 0;
foreach ($buddypress_meta as $meta_item) {
$buddypress_row[$i]['field_id'] = $meta_item['meta_name'];
$buddypress_row[$i]['user_id'] = $user_id;
// get GF and BP fields
$gform_field = RGFormsModel::get_field($form, $meta_item['meta_value']);
$bp_field = new BP_XProfile_Field();
$bp_field->bp_xprofile_field($meta_item['meta_name']);
// if bp field is a checkbox AND gf field is a checkbox, get array of input values
if ($bp_field->type == 'checkbox' && $gform_field['type'] == 'checkbox') {
$meta_value = RGFormsModel::get_lead_field_value($entry, $gform_field);
$meta_value = array_filter($meta_value, 'GFUser::not_empty');
} else {
if ($bp_field->type == 'multiselectbox' && $gform_field['type'] == 'checkbox') {
$meta_value = RGFormsModel::get_lead_field_value($entry, $gform_field);
$meta_value = array_filter($meta_value, 'GFUser::not_empty');
} else {
if ($bp_field->type == 'datebox' && $gform_field['type'] == 'date') {
$meta_value = strtotime(self::get_prepared_value($gform_field, $meta_item['meta_value'], $entry));
} else {
$meta_value = self::get_prepared_value($gform_field, $meta_item['meta_value'], $entry);
}
}
}
$buddypress_row[$i]['value'] = xprofile_sanitize_data_value_before_save($meta_value, $meta_item['meta_name']);
$buddypress_row[$i]['last_update'] = date('Y-m-d H:i:s');
$i++;
}
GFUserData::insert_buddypress_data($buddypress_row);
}