update_usermeta [ WordPress Function ]
update_usermeta ( $user_id, $meta_key, $meta_value )
| Parameters: |
|
| See: | |
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: update_user_meta, update_meta, delete_usermeta, update_user_status, update_post_meta
Update metadata of user.
There is no need to serialize values, they will be serialized if it is needed. The metadata key can only be a string with underscores. All else will be removed.
Will remove the metadata, if the meta value is empty.
Source
<?php
function update_usermeta( $user_id, $meta_key, $meta_value ) {
_deprecated_function( __FUNCTION__, '3.0', 'update_user_meta()' );
global $wpdb;
if ( !is_numeric( $user_id ) )
return false;
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
/** @todo Might need fix because usermeta data is assumed to be already escaped */
if ( is_string($meta_value) )
$meta_value = stripslashes($meta_value);
$meta_value = maybe_serialize($meta_value);
if (empty($meta_value)) {
return delete_usermeta($user_id, $meta_key);
}
$cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
if ( $cur )
do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
if ( !$cur )
$wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') );
else if ( $cur->meta_value != $meta_value )
$wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') );
else
return false;
clean_user_cache( $user_id );
wp_cache_delete( $user_id, 'user_meta' );
if ( !$cur )
do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value );
else
do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
return true;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/update usermeta « WordPress Codex
This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions.
codex.wordpress.org - WordPress › Support » Tags — update_usermeta
(forgot?) Register · WordPress › Support » update_usermeta ...
wordpress.org - #11254 (update_usermeta and delete_usermeta do not update or ...
The solution is to check for the existence of the global variable $current_user within the update_usermeta and delete_usermeta functions and either update it or ...
core.trac.wordpress.org - update_usermeta() WordPress function reference, arguments and ...
update_usermeta(). This function had been marked as deprecated since 3.0.0. Use update_user_meta(). Update metadata of user. There is no need to serialize ...
queryposts.com
Kullanýcý Tartýþmalarý [ wordpress.org ]
- madsrh123 on "Cannot save 'radio' button data"
- madsrh123 on "Cannot save 'radio' button data"
- liquidshile on "how to use "update_usermeta()" in an independent PHP file inside WP folder"
- whooami on "how to use "update_usermeta()" in an independent PHP file inside WP folder"
- liquidshile on "how to use "update_usermeta()" in an independent PHP file inside WP folder"
- StrangeAttractor on "is there a function like update_usermeta to update wp_user table?"
- Justin Tadlock on "is there a function like update_usermeta to update wp_user table?"
- StrangeAttractor on "is there a function like update_usermeta to update wp_user table?"
- Justin Tadlock on "is there a function like update_usermeta to update wp_user table?"
- StrangeAttractor on "is there a function like update_usermeta to update wp_user table?"