Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/14/2014 07:21:52 PM (8 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-activity/bp-activity-functions.php

    r7883 r7885  
    653653 * @since BuddyPress (1.2)
    654654 *
    655  * @param int $activity_id ID of the activity item whose metadata is being updated.
     655 * @param int $activity_id ID of the activity item whose metadata is being
     656 *        updated.
    656657 * @param string $meta_key Key of the metadata being updated.
    657658 * @param mixed $meta_value Value to be set.
     659 * @param mixed $prev_value Optional. If specified, only update existing
     660 *        metadata entries with the specified value. Otherwise, update all
     661 *        entries.
    658662 * @return bool True on success, false on failure.
    659663 */
    660 function bp_activity_update_meta( $activity_id, $meta_key, $meta_value ) {
     664function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_value = '' ) {
    661665
    662666    // Legacy - Make sure activity_id is valid
     
    669673
    670674    add_filter( 'query', 'bp_filter_metaid_column_name' );
    671     $retval = update_metadata( 'activity', $activity_id, $meta_key, $meta_value );
     675    $retval = update_metadata( 'activity', $activity_id, $meta_key, $meta_value, $prev_value );
    672676    remove_filter( 'query', 'bp_filter_metaid_column_name' );
    673677
Note: See TracChangeset for help on using the changeset viewer.