本文整理汇总了PHP中xprofile_get_field函数的典型用法代码示例。如果您正苦于以下问题:PHP xprofile_get_field函数的具体用法?PHP xprofile_get_field怎么用?PHP xprofile_get_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xprofile_get_field函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: cfbgr_register_member_types
/**
* Register member types.
*
* If the field type is set and has options. These options will dynamically build the member type
* Use the name to set options into the xProfile Field Admin UI eg: Has CF
*
* @since 1.0.0
*/
function cfbgr_register_member_types()
{
$saved_option = (int) bp_get_option('cfbgr_xfield_id', 0);
if (empty($saved_option)) {
return;
}
$field = xprofile_get_field($saved_option);
// This case means the option was not deleted when it oughts to be
if (empty($field->type_obj) || !is_a($field->type_obj, 'CF_BG_Member_Type_Field_Type')) {
bp_delete_option('cfbgr_xfield_id');
return;
}
// Object cache this field
buddypress()->groups->restrictions->member_type_field = $field;
$options = $field->get_children(true);
if (!is_array($options)) {
return;
}
foreach ($options as $member_type) {
if (empty($member_type->name)) {
continue;
}
bp_register_member_type(sanitize_key($member_type->name), array('labels' => array('name' => $member_type->name)));
}
}
开发者ID:WeFoster,项目名称:buddypress-group-restrictions,代码行数:33,代码来源:register.php
示例2: bp_xprofile_grant_bp_xprofile_change_field_visibility_for_logged_out_users
/**
* Grant the 'bp_xprofile_change_field_visibility' cap to logged-out users.
*
* @since 2.7.1
*
* @param bool $user_can
* @param int $user_id
* @param string $capability
* @return bool
*/
function bp_xprofile_grant_bp_xprofile_change_field_visibility_for_logged_out_users($user_can, $user_id, $capability)
{
if ('bp_xprofile_change_field_visibility' === $capability && 0 === $user_id) {
$field_id = bp_get_the_profile_field_id();
if ($field_id && ($field = xprofile_get_field($field_id))) {
$user_can = 'allowed' === $field->allow_custom_visibility;
}
}
return $user_can;
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:20,代码来源:bp-xprofile-caps.php
示例3: xprofile_filter_format_field_value_by_field_id
/**
* Apply display_filter() filters as defined by the BP_XProfile_Field_Type classes, when fetched
* by xprofile_get_field_data().
*
* @since 2.1.0
*
* @param mixed $field_value Field value.
* @param int $field_id Field type.
* @return string
*/
function xprofile_filter_format_field_value_by_field_id($field_value, $field_id)
{
$field = xprofile_get_field($field_id);
return xprofile_filter_format_field_value_by_type($field_value, $field->type, $field_id);
}
开发者ID:boonebgorges,项目名称:BuddyPress-1,代码行数:15,代码来源:bp-xprofile-filters.php
示例4: bp_xprofile_is_richtext_enabled_for_field
/**
* Is rich text enabled for this profile field?
*
* By default, rich text is enabled for textarea fields and disabled for all other field types.
*
* @since 2.4.0
*
* @param int|null $field_id Optional. Default current field ID.
* @return bool
*/
function bp_xprofile_is_richtext_enabled_for_field($field_id = null)
{
if (!$field_id) {
$field_id = bp_get_the_profile_field_id();
}
$field = xprofile_get_field($field_id);
$enabled = false;
if ($field instanceof BP_XProfile_Field) {
$enabled = (bool) $field->type_obj->supports_richtext;
}
/**
* Filters whether richtext is enabled for the given field.
*
* @since 2.4.0
*
* @param bool $enabled True if richtext is enabled for the field, otherwise false.
* @param int $field_id ID of the field.
*/
return apply_filters('bp_xprofile_is_richtext_enabled_for_field', $enabled, $field_id);
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:30,代码来源:bp-xprofile-functions.php
示例5: xprofile_admin_delete_field
/**
* Handles the deletion of a profile field (or field option).
*
* @since 1.0.0
* @global string $message The feedback message to show.
* @global $type The type of feedback message to show.
*
* @param int $field_id The field to delete.
* @param string $field_type The type of field being deleted.
* @param bool $delete_data Should the field data be deleted too.
*/
function xprofile_admin_delete_field($field_id, $field_type = 'field', $delete_data = false)
{
global $message, $type;
// Switch type to 'option' if type is not 'field'.
// @todo trust this param.
$field_type = 'field' == $field_type ? __('field', 'buddypress') : __('option', 'buddypress');
$field = xprofile_get_field($field_id);
if (!$field->delete((bool) $delete_data)) {
$message = sprintf(__('There was an error deleting the %s. Please try again.', 'buddypress'), $field_type);
$type = 'error';
} else {
$message = sprintf(__('The %s was deleted successfully!', 'buddypress'), $field_type);
$type = 'success';
/**
* Fires at the end of the field deletion process, if successful.
*
* @since 1.0.0
*
* @param BP_XProfile_Field $field Current BP_XProfile_Field object.
*/
do_action('xprofile_fields_deleted_field', $field);
}
unset($_GET['mode']);
xprofile_admin($message, $type);
}
开发者ID:boonebgorges,项目名称:BuddyPress-1,代码行数:36,代码来源:bp-xprofile-admin.php
示例6: test_xprofile_get_field_should_prime_field_cache
/**
* @ticket BP6638
* @group cache
*/
public function test_xprofile_get_field_should_prime_field_cache()
{
global $wpdb;
$g = $this->factory->xprofile_group->create();
$f = $this->factory->xprofile_field->create(array('field_group_id' => $g, 'type' => 'selectbox', 'name' => 'Foo'));
$num_queries = $wpdb->num_queries;
// Prime the cache.
$field_1 = xprofile_get_field($f);
$num_queries++;
$this->assertSame($num_queries, $wpdb->num_queries);
// No more queries.
$field_2 = xprofile_get_field($f);
$this->assertEquals($field_1, $field_2);
$this->assertSame($num_queries, $wpdb->num_queries);
}
开发者ID:dcavins,项目名称:buddypress-svn,代码行数:19,代码来源:functions.php
示例7: bp_get_the_profile_field_options
/**
* Retrieves field options HTML for field types of 'selectbox', 'multiselectbox', 'radio', 'checkbox', and 'datebox'.
*
* @since 1.1.0
*
*
* @param array $args {
* Array of optional arguments.
* @type string|bool $type Type of datebox. False if it's not a
* datebox, otherwise 'day, 'month', or 'year'. Default: false.
* @type int $user_id ID of the user whose profile values should be
* used when rendering options. Default: displayed user.
* }
*
* @return string $vaue Field options markup.
*/
function bp_get_the_profile_field_options($args = array())
{
global $field;
$args = bp_parse_args($args, array('type' => false, 'user_id' => bp_displayed_user_id()), 'get_the_profile_field_options');
/**
* In some cases, the $field global is not an instantiation of the BP_XProfile_Field class.
* However, we have to make sure that all data originally in $field gets merged back in, after reinstantiation.
*/
if (!method_exists($field, 'get_children')) {
$field_obj = xprofile_get_field($field->id);
foreach ($field as $field_prop => $field_prop_value) {
if (!isset($field_obj->{$field_prop})) {
$field_obj->{$field_prop} = $field_prop_value;
}
}
$field = $field_obj;
}
ob_start();
$field->type_obj->edit_field_options_html($args);
$html = ob_get_contents();
ob_end_clean();
return $html;
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:39,代码来源:bp-xprofile-template.php
示例8: edit_user
}
/* Update the user. */
if (!$errors->get_error_code()) {
/* Update user with fields from $_POST and get response. */
$response = edit_user($user_id);
/* If there are no errors and Extended Profiles are active... */
if (!is_wp_error($response) && $xprofile_active) {
/* Update BuddyPress fields. */
if (isset($bp_field_ids)) {
/* Replace errors with BuddyPress update errors. */
$errors = new WP_Error();
/* Update each field or record error. */
foreach ((array) $bp_field_ids as $field_id) {
$value = isset($_POST['field_' . $field_id]) ? $_POST['field_' . $field_id] : '';
if (!xprofile_set_field_data($field_id, $user_id, $value, $is_required[$field_id])) {
$field = xprofile_get_field($field_id);
$errors->add('field_' . $field_id, sprintf(__('Error updating \'%s\'.', 'membership'), $field->name));
unset($field);
}
}
}
} else {
/* Replace field errors with update errors. */
$errors = $response;
}
}
if (isset($errors) && is_object($errors) && $errors->get_error_code()) {
$msg = '<div class="alert alert-error">' . implode('<br>', $errors->get_error_messages()) . '</div>';
}
}
do_action('edit_user_profile_update', $user_id);
开发者ID:vilmark,项目名称:vilmark_main,代码行数:31,代码来源:bp.account.form.php
示例9: cfbgr_enqueue_js
/**
* Enqueue the script.
*
* @since 1.0.0
*/
function cfbgr_enqueue_js()
{
$bp = buddypress();
$min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
if (!cfbgr_is_restriction_js()) {
return;
}
if (is_null($bp->groups->restrictions->member_type_field)) {
$saved_option = (int) bp_get_option('cfbgr_xfield_id', 0);
if (empty($saved_option)) {
return;
}
$field = xprofile_get_field($saved_option);
} else {
$field = $bp->groups->restrictions->member_type_field;
}
$options = $field->get_children(true);
if (!is_array($options)) {
return;
}
$script_data = array();
foreach ($options as $option) {
// Default description
// Use the xProfile API to set customs in the textareas of the member type field
$description = sprintf(__('Only allow users having the type: %s', 'buddypress-group-restrictions'), $option->name);
if (!empty($option->description)) {
$description = $option->description;
}
$script_data[sanitize_key($option->name)] = array('public' => sprintf(__('%s to join the group.', 'buddypress-group-restrictions'), $description), 'private' => sprintf(__('%s to request membership to the group.', 'buddypress-group-restrictions'), $description));
}
wp_enqueue_script('cfbgr-js', cfbgr_get_js_url() . "script{$min}.js", array('jquery'), cfbgr_get_version(), true);
wp_localize_script('cfbgr-js', '_cfbGRTypes', $script_data);
}
开发者ID:WeFoster,项目名称:buddypress-group-restrictions,代码行数:38,代码来源:functions.php
示例10: get
//.........这里部分代码省略.........
if (empty($member_types)) {
$member_types = array('null');
}
}
$member_types_fields = BP_XProfile_Field::get_fields_for_member_type($member_types);
$include_field_ids += array_keys($member_types_fields);
}
}
$in_sql = '';
if (!empty($include_field_ids)) {
$include_field_ids_cs = implode(',', array_map('intval', $include_field_ids));
$in_sql = " AND id IN ({$include_field_ids_cs}) ";
}
// Fetch the fields.
$field_ids = $wpdb->get_col("SELECT id FROM {$bp->profile->table_name_fields} WHERE group_id IN ( {$group_ids_in} ) AND parent_id = 0 {$exclude_fields_sql} {$in_sql} ORDER BY field_order");
// Bail if no fields.
if (empty($field_ids)) {
return $groups;
}
$field_ids = array_map('intval', $field_ids);
// Prime the field cache.
$uncached_field_ids = bp_get_non_cached_ids($field_ids, 'bp_xprofile_fields');
if (!empty($uncached_field_ids)) {
$_uncached_field_ids = implode(',', array_map('intval', $uncached_field_ids));
$uncached_fields = $wpdb->get_results("SELECT * FROM {$bp->profile->table_name_fields} WHERE id IN ({$_uncached_field_ids})");
foreach ($uncached_fields as $uncached_field) {
$fid = intval($uncached_field->id);
wp_cache_set($fid, $uncached_field, 'bp_xprofile_fields');
}
}
// Pull field objects from the cache.
$fields = array();
foreach ($field_ids as $field_id) {
$fields[] = xprofile_get_field($field_id);
}
// Store field IDs for meta cache priming.
$object_ids['field'] = $field_ids;
// Maybe fetch field data.
if (!empty($r['fetch_field_data'])) {
// Get field data for user ID.
if (!empty($field_ids) && !empty($r['user_id'])) {
$field_data = BP_XProfile_ProfileData::get_data_for_user($r['user_id'], $field_ids);
}
// Remove data-less fields, if necessary.
if (!empty($r['hide_empty_fields']) && !empty($field_ids) && !empty($field_data)) {
// Loop through the results and find the fields that have data.
foreach ((array) $field_data as $data) {
// Empty fields may contain a serialized empty array.
$maybe_value = maybe_unserialize($data->value);
// Valid field values of 0 or '0' get caught by empty(), so we have an extra check for these. See #BP5731.
if ((!empty($maybe_value) || '0' == $maybe_value) && false !== ($key = array_search($data->field_id, $field_ids))) {
// Fields that have data get removed from the list.
unset($field_ids[$key]);
}
}
// The remaining members of $field_ids are empty. Remove them.
foreach ($fields as $field_key => $field) {
if (in_array($field->id, $field_ids)) {
unset($fields[$field_key]);
}
}
// Reset indexes.
$fields = array_values($fields);
}
// Field data was found.
if (!empty($fields) && !empty($field_data) && !is_wp_error($field_data)) {
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:67,代码来源:class-bp-xprofile-group.php
示例11: t_value_profile_view
/**
* Filters field values on profile view template.
*/
public function t_value_profile_view($value, $field_type)
{
global $field;
// Only for fields with options
if (in_array($field_type, array('radio', 'checkbox', 'selectbox', 'multiselectbox'))) {
$bp_field = xprofile_get_field($field->id);
$options = $bp_field->get_children();
switch ($field_type) {
case 'radio':
case 'selectbox':
$_value = false;
foreach ($options as $option) {
if (isset($option->name) && $option->name == $field->data->value) {
$_value = icl_t($this->_context, $this->sanitize_option_basename($option, $field->id) . ' name', $option->name);
}
}
if ($_value) {
// Expected format is search link
$value = str_replace(">{$field->data->value}</a>", ">{$_value}</a>", $value, $count);
if (!$count) {
$value = $_value;
}
}
break;
case 'multiselectbox':
case 'checkbox':
foreach ($options as $option) {
$_value = icl_t($this->_context, $this->sanitize_option_basename($option, $field->id) . ' name', $option->name);
// Expected format is search link
$value = str_replace(">{$option->name}</a>", ">{$_value}</a>", $value, $count);
// CSV list
if (!$count && strpos($value, $option->name) !== false) {
$_ex_values = explode(',', $value);
if (!empty($_ex_values)) {
foreach ($_ex_values as &$v) {
if (trim($v) == $option->name) {
$v = $_value;
}
}
$value = implode(', ', $_ex_values);
}
}
}
break;
default:
break;
}
}
return $value;
}
开发者ID:OnTheGoSystems,项目名称:buddypress-multilingual,代码行数:53,代码来源:class.xprofile.php
示例12: update_member_type
/**
* Update the member type of a user when member type field is updated
*
* @param type $data_field
* @return type
*/
public function update_member_type($data_field)
{
$field = xprofile_get_field($data_field->field_id);
//we only need to worry about member type field
if ($field->type != 'membertype') {
return;
}
$user_id = $data_field->user_id;
$member_type = maybe_unserialize($data_field->value);
//validate too?
if (empty($member_type)) {
//remove all member type?
bp_set_member_type($user_id, '');
return;
}
//should we validate member type here? I don't think as only validated data will be passed here
bp_set_member_type($user_id, $member_type);
}
开发者ID:buddydev,项目名称:bp-xprofile-member-type-field,代码行数:24,代码来源:bp-xprofile-member-type-field-loader.php
示例13: render_xprofile_field
/**
* Generates the HTML code for a single XProfile input field.
*
* Code is taken from the BuddyPress default theme file:
* plugins/buddypress/bp-themes/bp-default/registration/register.php
*
* @since 1.0.1.0
* @param int $field_id The XProfile field ID.
* @param mixed $field_value Value of the field.
* @return string The HTML code to display the field.
*/
public function render_xprofile_field($field_id, $field_value = null, $visibility = false)
{
global $field;
$field = xprofile_get_field($field_id);
ob_start();
?>
<div class="ms-form-element ms-form-element-xprofile editfield field-<?php
echo $field_id;
?>
">
<?php
if ('textarea' == bp_get_the_profile_field_type()) {
?>
<label for="<?php
bp_the_profile_field_input_name();
?>
"><?php
bp_the_profile_field_name();
?>
<?php
if (bp_get_the_profile_field_is_required()) {
_e('(required)', 'buddypress');
}
?>
</label>
<?php
do_action(bp_get_the_profile_field_errors_action());
?>
<textarea rows="5" cols="40" name="<?php
bp_the_profile_field_input_name();
?>
" id="<?php
bp_the_profile_field_input_name();
?>
"><?php
bp_the_profile_field_edit_value();
?>
</textarea>
<?php
} elseif ('selectbox' == bp_get_the_profile_field_type()) {
?>
<label for="<?php
bp_the_profile_field_input_name();
?>
"><?php
bp_the_profile_field_name();
?>
<?php
if (bp_get_the_profile_field_is_required()) {
_e('(required)', 'buddypress');
}
?>
</label>
<?php
do_action(bp_get_the_profile_field_errors_action());
?>
<select name="<?php
bp_the_profile_field_input_name();
?>
" id="<?php
bp_the_profile_field_input_name();
?>
">
<?php
bp_the_profile_field_options();
?>
</select>
<?php
} elseif ('multiselectbox' == bp_get_the_profile_field_type()) {
?>
<label for="<?php
bp_the_profile_field_input_name();
?>
"><?php
bp_the_profile_field_name();
?>
<?php
if (bp_get_the_profile_field_is_required()) {
_e('(required)', 'buddypress');
}
?>
</label>
<?php
//.........这里部分代码省略.........
开发者ID:jsandlin85,项目名称:SkylineSports,代码行数:101,代码来源:class-ms-addon-profilefields.php
示例14: test_field_cache_should_be_invalidated_on_save
/**
* @ticket BP6638
*/
public function test_field_cache_should_be_invalidated_on_save()
{
$g = $this->factory->xprofile_group->create();
$f = $this->factory->xprofile_field->create(array('field_group_id' => $g, 'name' => 'Foo'));
$field = xprofile_get_field($f);
$this->assertSame('Foo', $field->name);
$field->name = 'Bar';
$this->assertNotEmpty($field->save());
$field_2 = xprofile_get_field($f);
$this->assertSame('Bar', $field_2->name);
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:14,代码来源:cache.php
示例15: buatp_get_field_name_by_id
function buatp_get_field_name_by_id($field_id)
{
return xprofile_get_field($field_id)->name;
}
开发者ID:jfeliweb,项目名称:BuddyPress-User-Account-Type,代码行数:4,代码来源:bp-user-type-functions.php
示例16: test_update_position_should_invalidate_cache
/**
* @ticket BP7112
*/
public function test_update_position_should_invalidate_cache()
{
$group = $this->factory->xprofile_group->create();
$field = $this->factory->xprofile_field->create(array('field_group_id' => $group));
// Prime cache.
$fetched_field = xprofile_get_field($field);
$new_field_order = 12345;
// Update field position.
BP_XProfile_Field::update_position($field, $new_field_order, $group);
// Cache call should miss; fresh data should be fetched.
$updated_fetched_field = xprofile_get_field($field);
$this->assertEquals($new_field_order, $updated_fetched_field->field_order);
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:16,代码来源:class-bp-xprofile-field.php
注:本文中的xprofile_get_field函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论