OK, now when I delete any user, the favorite counter still gonna count the fav of the deleted user, to clear that I just needed add a function in my functions.php file, here it is:
function remove_fav_on_delete_user( $user_id ) {
global $wpdb;
$results = $wpdb->get_var( "SELECT 'wp_usermeta'.'meta_value' FROM 'DATABASE'.'wp_usermeta' WHERE 'wp_usermeta'.'user_id' = '$user_id' AND 'wp_usermeta'.'meta_key' LIKE '%wpfp_favorites%'" );
$results = unserialize($results);
foreach ($results as $key => $value) {
$fav_id = $value;
$meta_value = $wpdb->get_var( "UPDATE 'DATABASE'.'wp_postmeta' SET 'meta_value' = 'meta_value' -1 WHERE 'wp_postmeta'.'post_id' = '$fav_id' AND 'wp_postmeta'.'meta_key' LIKE '%wpfp_favorites%'" );
}
}
I hope this is useful for someone and that the author includes something of this in the next update of the plugin.
Cheers!
-
This reply was modified 7 years, 9 months ago by Joaowo.