Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/14/2014 01:41:22 PM (11 years ago)
Author:
boonebgorges
Message:

Introduce bp_xprofile_add_meta().

See #5400

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile/bp-xprofile-functions.php

    r7862 r7878  
    643643}
    644644
     645/**
     646 * Add a piece of xprofile metadata.
     647 *
     648 * @since BuddyPress (2.0.0)
     649 *
     650 * @param int $object_id ID of the object the metadata belongs to.
     651 * @param string $object_type Type of object. 'group', 'field', or 'data'.
     652 * @param string $meta_key Metadata key.
     653 * @param mixed $meta_value Metadata value.
     654 * @param bool $unique. Optional. Whether to enforce a single metadata value
     655 *        for the given key. If true, and the object already has a value for
     656 *        the key, no change will be made. Default: false.
     657 * @return int|bool The meta ID on successful update, false on failure.
     658 */
     659function bp_xprofile_add_meta( $object_id, $object_type, $meta_key, $meta_value, $unique = false ) {
     660    add_filter( 'query', 'bp_filter_metaid_column_name' );
     661    add_filter( 'query', 'bp_xprofile_filter_meta_query' );
     662    $retval = add_metadata( 'xprofile_' . $object_type , $object_id, $meta_key, $meta_value, $unique );
     663    remove_filter( 'query', 'bp_filter_metaid_column_name' );
     664    remove_filter( 'query', 'bp_xprofile_filter_meta_query' );
     665
     666    return $retval;
     667}
     668
    645669function bp_xprofile_update_fieldgroup_meta( $field_group_id, $meta_key, $meta_value ) {
    646670    return bp_xprofile_update_meta( $field_group_id, 'group', $meta_key, $meta_value );
Note: See TracChangeset for help on using the changeset viewer.