• Resolved codings

    (@codings)


    I searched for “wordpress sync comments username after account is created” and this post (Sync User Comments Posted Before Installing UM) showed up first in the results. I was going to reference it because it seems like a similar question, and then I realized I was the one who posted it ??

    So, building on that… if, before implementing Ultimate Member, the guest user (unregistered) was leaving comments on multiple posts with the same email address, but with different spellings of their name: 12345 on one post, 123456 on another, 1234567 on another.

    THEN they create an actual account, same email address, but register the name on their account as 1234567890, all of their previous comments show up on the tab (as referenced in the post linked above), but going back to each individual comment, the names are different as they originally typed them there.

    Question is: is there a way to sync the old comment guest names to the new registered username?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support andrewshu

    (@andrewshu)

    Hello @codings

    Sorry, I can’t understand your question. Please describe in more detail.

    Regards.

    Thread Starter codings

    (@codings)

    Sorry about that. When a guest posts comments on blog posts, using various names but the same email address, and then signs up for an account with that email and fills out their UM profile, can the names used on the comments be synced with the name now used on the member account?

    Plugin Support andrewshu

    (@andrewshu)

    Hello @codings

    Unfortunately, this functionality does not exist in our plugin at this time.

    Regards.

    @codings

    You can try this code snippet syncing your wp_comments table at Registration
    with user_login and user_id for comments by author user_email

    add_action( 'um_registration_set_extra_data', 'um_registration_sync_comments', 10, 3 );
    
    function um_registration_sync_comments( $user_id, $args, $form_data ) {
    
        global $wpdb;
        $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}comments SET comment_author = %s, user_id = %s 
                                                WHERE comment_author_email = %s", $args['user_login'], $user_id, $args['user_email'] ));
    }

    Install by adding the code snippet to your active theme’s functions.php file
    or use the “Code Snippets” Plugin

    https://www.ads-software.com/plugins/code-snippets/

    Thread Starter codings

    (@codings)

    Thanks @missveronicatv

    Will try that. Thank you so much for taking the time to reply and provide the snippet!

    Plugin Support andrewshu

    (@andrewshu)

    Hi @codings

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. ??

    Regards

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Sync Username on Comments Posted Before Creating Account’ is closed to new replies.