Make WordPress Core


Ignore:
Timestamp:
09/10/2009 02:43:45 PM (15 years ago)
Author:
ryan
Message:

More add/delete/update actions. Props Demitrious Kelly. see #10750

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/user.php

    r11397 r11909  
    308308    $meta_value = trim( $meta_value );
    309309
     310    $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
     311
     312    if ( $cur && $cur->umeta_id )
     313        do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
     314
    310315    if ( ! empty($meta_value) )
    311316        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) );
     
    314319
    315320    wp_cache_delete($user_id, 'users');
     321
     322    if ( $cur && $cur->umeta_id )
     323        do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
    316324
    317325    return true;
     
    400408
    401409    $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
     410
     411    if ( $cur )
     412        do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
     413
    402414    if ( !$cur )
    403415        $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') );
     
    408420
    409421    wp_cache_delete($user_id, 'users');
     422
     423    if ( !$cur )
     424        do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value );
     425    else
     426        do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
    410427
    411428    return true;
Note: See TracChangeset for help on using the changeset viewer.