function theme_achievements() {
$user_id = get_current_user_id();
if ( empty( $user_id ) ) {
return false;
}
if( $value >= '0' && $value <= '499' ) {
add_user_meta( $user_id, 'author_level', array( 'lvl-0', '' ) );
} elseif( $value >= '500' && $value <= '999' ) {
update_user_meta( $user_id, 'author_level', array( 'lvl-1', '' ) );
} else {
...
}
}
add_action( 'wp_head', 'theme_achievements' );
With the function above I created an custom user meta_key (based on levels).
While looking inside my wp database (phpMyAdmin) to see if the meta_key is created and update properly, I noticed multiple author_level
entries that keep increasing everything I load the page.
Inside the database user_id
, meta_key
, and meta_value
are all the same but each entry has an unique umeta_id
. Is this normal? I prefer to have just one entry per user to keep the database "clean".