本文整理汇总了PHP中bp_xprofile_delete_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_xprofile_delete_meta函数的具体用法?PHP bp_xprofile_delete_meta怎么用?PHP bp_xprofile_delete_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_xprofile_delete_meta函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_xprofile_update_meta
function bp_xprofile_update_meta($object_id, $object_type, $meta_key, $meta_value)
{
global $nxtdb, $bp;
$object_id = (int) $object_id;
if (empty($object_id)) {
return false;
}
if (!isset($object_type)) {
return false;
}
if (!in_array($object_type, array('group', 'field', 'data'))) {
return false;
}
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
if (is_string($meta_value)) {
$meta_value = stripslashes($nxtdb->escape($meta_value));
}
$meta_value = maybe_serialize($meta_value);
if (empty($meta_value)) {
return bp_xprofile_delete_meta($object_id, $object_type, $meta_key);
}
$cur = $nxtdb->get_row($nxtdb->prepare("SELECT * FROM " . $bp->profile->table_name_meta . " WHERE object_id = %d AND object_type = %s AND meta_key = %s", $object_id, $object_type, $meta_key));
if (empty($cur)) {
$nxtdb->query($nxtdb->prepare("INSERT INTO " . $bp->profile->table_name_meta . " ( object_id, object_type, meta_key, meta_value ) VALUES ( %d, %s, %s, %s )", $object_id, $object_type, $meta_key, $meta_value));
} else {
if ($cur->meta_value != $meta_value) {
$nxtdb->query($nxtdb->prepare("UPDATE " . $bp->profile->table_name_meta . " SET meta_value = %s WHERE object_id = %d AND object_type = %s AND meta_key = %s", $meta_value, $object_id, $object_type, $meta_key));
} else {
return false;
}
}
// Update the cached object and recache
nxt_cache_set('bp_xprofile_meta_' . $object_type . '_' . $object_id . '_' . $meta_key, $meta_value, 'bp');
return true;
}
示例2: xprofile_admin_manage_field
/**
* Handles the adding or editing of profile field data for a user.
*
* @param int $group_id ID of the group.
* @param int|null $field_id ID of the field being managed.
*/
function xprofile_admin_manage_field($group_id, $field_id = null)
{
global $wpdb, $message, $groups;
$bp = buddypress();
if (is_null($field_id)) {
$field = new BP_XProfile_Field();
} else {
$field = xprofile_get_field($field_id);
}
$field->group_id = $group_id;
if (isset($_POST['saveField'])) {
if (BP_XProfile_Field::admin_validate()) {
$field->is_required = $_POST['required'];
$field->type = $_POST['fieldtype'];
$field->name = $_POST['title'];
if (!empty($_POST['description'])) {
$field->description = $_POST['description'];
} else {
$field->description = '';
}
if (!empty($_POST["sort_order_{$field->type}"])) {
$field->order_by = $_POST["sort_order_{$field->type}"];
}
$field->field_order = $wpdb->get_var($wpdb->prepare("SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id));
if (empty($field->field_order) || is_wp_error($field->field_order)) {
$field->field_order = (int) $wpdb->get_var($wpdb->prepare("SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id));
$field->field_order++;
}
// For new profile fields, set the $field_id. For existing profile
// fields, this will overwrite $field_id with the same value.
$field_id = $field->save();
if (empty($field_id)) {
$message = __('There was an error saving the field. Please try again.', 'buddypress');
$type = 'error';
} else {
$message = __('The field was saved successfully.', 'buddypress');
$type = 'success';
// @todo remove these old options
if (1 == $field_id) {
bp_update_option('bp-xprofile-fullname-field-name', $field->name);
}
// Set member types.
if (isset($_POST['has-member-types'])) {
$member_types = array();
if (isset($_POST['member-types'])) {
$member_types = stripslashes_deep($_POST['member-types']);
}
$field->set_member_types($member_types);
}
// Validate default visibility.
if (!empty($_POST['default-visibility']) && in_array($_POST['default-visibility'], wp_list_pluck(bp_xprofile_get_visibility_levels(), 'id'))) {
bp_xprofile_update_field_meta($field_id, 'default_visibility', $_POST['default-visibility']);
}
// Validate custom visibility.
if (!empty($_POST['allow-custom-visibility']) && in_array($_POST['allow-custom-visibility'], array('allowed', 'disabled'))) {
bp_xprofile_update_field_meta($field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility']);
}
// Validate signup.
if (!empty($_POST['signup-position'])) {
bp_xprofile_update_field_meta($field_id, 'signup_position', (int) $_POST['signup-position']);
} else {
bp_xprofile_delete_meta($field_id, 'field', 'signup_position');
}
/**
* Fires at the end of the process to save a field for a user, if successful.
*
* @since 1.0.0
*
* @param BP_XProfile_Field $field Current BP_XProfile_Field object.
*/
do_action('xprofile_fields_saved_field', $field);
$groups = bp_xprofile_get_groups();
}
unset($_GET['mode']);
xprofile_admin($message, $type);
} else {
$field->render_admin_form($message);
}
} else {
$field->render_admin_form();
}
}
示例3: __update_xprofile_meta
/**
* Helper function for handling xProfile Meta
*
* @since 1.0
*
* @param int $object_id
* @param string $object_type
* @param string $meta_key
* @param string $meta_value
*
*/
private function __update_xprofile_meta($object_id, $object_type, $meta_key, $meta_value = '')
{
if (empty($meta_value) || !$meta_value) {
bp_xprofile_delete_meta($object_id, $object_type, $meta_key);
} elseif (!bp_xprofile_get_meta($object_id, $object_type, $meta_key)) {
bp_xprofile_add_meta($object_id, $object_type, $meta_key, $meta_value);
} else {
bp_xprofile_update_meta($object_id, $object_type, $meta_key, $meta_value);
}
}
开发者ID:nightbook,项目名称:buddypress-admin-global-profile-fields,代码行数:21,代码来源:bp-admin-only-profile-fields.php
示例4: test_bp_xprofile_delete_meta_with_delete_all
/**
* @group xprofilemeta
* @group bp_xprofile_delete_meta
*/
public function test_bp_xprofile_delete_meta_with_delete_all()
{
// With no meta key, don't delete for all items - just delete
// all for a single item
$g1 = $this->factory->xprofile_group->create();
$g2 = $this->factory->xprofile_group->create();
bp_xprofile_add_meta($g1, 'group', 'foo', 'bar');
bp_xprofile_add_meta($g1, 'group', 'foo1', 'bar1');
bp_xprofile_add_meta($g2, 'group', 'foo', 'bar');
bp_xprofile_add_meta($g2, 'group', 'foo1', 'bar1');
$this->assertTrue(bp_xprofile_delete_meta($g1, 'group', 'foo', '', true));
$this->assertSame('', bp_xprofile_get_meta($g1, 'group', 'foo'));
$this->assertSame('', bp_xprofile_get_meta($g2, 'group', 'foo'));
$this->assertSame('bar1', bp_xprofile_get_meta($g1, 'group', 'foo1'));
$this->assertSame('bar1', bp_xprofile_get_meta($g2, 'group', 'foo1'));
}
示例5: set_member_types
/**
* Sets the member types for this field.
*
* @since 2.4.0
*
* @param array $member_types Array of member types. Can include 'null' (users with no type) in addition to any
* registered types.
* @param bool $append Whether to append to existing member types. If false, all existing member type
* associations will be deleted before adding your `$member_types`. Default false.
*
* @return array Member types for the current field, after being saved.
*/
public function set_member_types($member_types, $append = false)
{
// Unset invalid member types.
$types = array();
foreach ($member_types as $member_type) {
// 'null' is a special case - it represents users without a type.
if ('null' === $member_type || bp_get_member_type_object($member_type)) {
$types[] = $member_type;
}
}
// When `$append` is false, delete all existing types before adding new ones.
if (!$append) {
bp_xprofile_delete_meta($this->id, 'field', 'member_type');
/*
* We interpret an empty array as disassociating the field from all types. This is
* represented internally with the '_none' flag.
*/
if (empty($types)) {
bp_xprofile_add_meta($this->id, 'field', 'member_type', '_none');
}
}
/*
* Unrestricted fields are represented in the database as having no 'member_type'.
* We detect whether a field is being set to unrestricted by checking whether the
* list of types passed to the method is the same as the list of registered types,
* plus the 'null' pseudo-type.
*/
$_rtypes = bp_get_member_types();
$rtypes = array_values($_rtypes);
$rtypes[] = 'null';
sort($types);
sort($rtypes);
// Only save if this is a restricted field.
if ($types !== $rtypes) {
// Save new types.
foreach ($types as $type) {
bp_xprofile_add_meta($this->id, 'field', 'member_type', $type);
}
}
// Reset internal cache of member types.
$this->member_types = null;
/**
* Fires after a field's member types have been updated.
*
* @since 2.4.0
*
* @param BP_XProfile_Field $this Field object.
*/
do_action('bp_xprofile_field_set_member_type', $this);
// Refetch fresh items from the database.
return $this->get_member_types();
}
示例6: _likebtn_delete_bp_member_votes
function _likebtn_delete_bp_member_votes($entity_id)
{
global $wpdb;
if (!_likebtn_is_bp_active()) {
return false;
}
$bp_xprofile = $wpdb->get_row("\n SELECT id\n FROM " . $wpdb->prefix . "bp_xprofile_data\n WHERE user_id = {$entity_id}\n ");
if (!empty($bp_xprofile)) {
bp_xprofile_delete_meta($entity_id, LIKEBTN_BP_XPROFILE_OBJECT_TYPE, LIKEBTN_META_KEY_LIKES);
bp_xprofile_delete_meta($entity_id, LIKEBTN_BP_XPROFILE_OBJECT_TYPE, LIKEBTN_META_KEY_DISLIKES);
bp_xprofile_delete_meta($entity_id, LIKEBTN_BP_XPROFILE_OBJECT_TYPE, LIKEBTN_META_KEY_LIKES_MINUS_DISLIKES);
return true;
}
return false;
}
示例7: delete_condition
/**
* Deletes the condition associated with a profile field
*
* @param type $field_id
*/
public function delete_condition($field_id)
{
bp_xprofile_delete_meta($field_id, 'field', 'xprofile_condition_display');
bp_xprofile_delete_meta($field_id, 'field', 'xprofile_condition_other_field');
bp_xprofile_delete_meta($field_id, 'field', 'xprofile_condition_operator');
bp_xprofile_delete_meta($field_id, 'field', 'xprofile_condition_other_field_value');
}
示例8: update_xprofile_member_types
/**
* Update a field's or group's member types meta value
*
* @since 1.0.0
*
* @uses BP_XProfile_Field_For_Member_Types::get_xprofile_member_types()
* @uses bp_xprofile_delete_meta()
* @uses bp_xprofile_add_meta()
*
* @param int $object_id Field or group ID
* @param string $meta_type Type of meta, either 'field' or 'group'
* @param array $selected_types Selected member type names
* @return bool Update success or failure
*/
public function update_xprofile_member_types($object_id, $meta_type, $selected_types)
{
$current_types = $this->get_xprofile_member_types($object_id, $meta_type);
// Delete unselected types
foreach ($current_types as $type) {
if (!in_array($type, $selected_types)) {
bp_xprofile_delete_meta($object_id, $meta_type, 'member-type', $type, false);
}
}
// Add new selected types
foreach ($selected_types as $type) {
if (!in_array($type, $current_types)) {
bp_xprofile_add_meta($object_id, $meta_type, 'member-type', $type, false);
}
}
return true;
}
开发者ID:boonebgorges,项目名称:bp-xprofile-field-for-member-types,代码行数:31,代码来源:bp-xprofile-field-for-member-types.php