Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/14/2014 07:21:52 PM (10 years ago)
Author:
boonebgorges
Message:

Add support for prev_value param to _update_meta() functions

This parameter, inherited from update_metadata(), allows you to limit your
updates only to rows where the meta_value matches your specified prev_value.

See #5400

File:
1 edited

Legend:

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

    r7883 r7885  
    634634 * @param string $meta_key Key of the metadata being updated.
    635635 * @param mixed $meta_value Value of the metadata being updated.
     636 * @param mixed $prev_value Optional. If specified, only update existing
     637 *        metadata entries with the specified value. Otherwise, update all
     638 *        entries.
    636639 * @return bool True on success, false on failure.
    637640 */
    638 function bp_xprofile_update_meta( $object_id, $object_type, $meta_key, $meta_value ) {
     641function bp_xprofile_update_meta( $object_id, $object_type, $meta_key, $meta_value, $prev_value = '' ) {
    639642
    640643    // Legacy - sanitize meta_key
     
    643646    add_filter( 'query', 'bp_filter_metaid_column_name' );
    644647    add_filter( 'query', 'bp_xprofile_filter_meta_query' );
    645     $retval = update_metadata( 'xprofile_' . $object_type, $object_id, $meta_key, $meta_value );
     648    $retval = update_metadata( 'xprofile_' . $object_type, $object_id, $meta_key, $meta_value, $prev_value );
    646649    remove_filter( 'query', 'bp_xprofile_filter_meta_query' );
    647650    remove_filter( 'query', 'bp_filter_metaid_column_name' );
Note: See TracChangeset for help on using the changeset viewer.