FIXED! Update user's old comments email address!
-
Hello there,
in this thread, the amazing Ravi Patel pointed me towards a solution for my issue that old comments wouldn’t be updated with a new (registered) user’s email address. He fixed it with a simple function that I thought might as well be included in the plugin. Mention him please though as it’s his work, not mine.
I’ve tested it and it works beautifully!
function user_profile_update($user_id) { $commentarr = array(); global $wpdb; if( !current_user_can( 'edit_user', $user_id ) ){ return false; } if(isset($_POST['email'])): echo $email = esc_attr($_POST['email']); $wpdb->query("UPDATE $wpdb->comments SET comment_author_email='$email' WHERE user_id=$user_id"); endif; } add_action('personal_options_update','my_profile_update', 10,2); add_action('profile_update', 'user_profile_update', 10,2);
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘FIXED! Update user's old comments email address!’ is closed to new replies.