• Resolved gamicord

    (@gamicord)


    Hello Sir,

    I want a Unique ID to be created for each of my Users when they sign up or register on my website using UsersWP.

    And I want to be able to place this Unique ID Number on their Profile Page.

    How do I achieve this with UsersWP ?

    Needing to hear from you soon.

    Regards.

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

    (@alexrollin)

    Hello,

    with UsersWP you can add a new custom field to the account form. You can make the field admin only. When a new user registers, you can add a unique ID in that field. Then you can use the profile tabs feature to easily display that unique ID on their profile.

    Thread Starter gamicord

    (@gamicord)

    Thanks for this reply. I sincerely appreciate it.

    At least, it’s a sign that shortcuts can still be found what I want– even if they are still not the desirable solution.

    However, the process you are talking about will be cumbersome and too manual. I have to be returning to the backend everytime to assign each Registered User, a Unique ID manually.

    This for me is too much work, and it will wreck me when the number increases, and I get busy with other things.

    The solution I seek, is one that will be automatically generated at Registration, using the WordPress “register_new_user” function.

    I am not too Technical. I just started Learning Python, JavaScript and PHP.

    Now, I have been able to get a PHP Code Snippet from somewhere. 

    Here’s the link to the Code file:

    https://drive.google.com/uc?export=download&id=1L18nTfh9DVkQncyxi-TlkOCVTrWyOL_I

    What I need you to do, is to help me modify the Code to fit into your UsersWP plugin.

    So that when I install UsersWP, the function of creating Custom User ID will be available to me during the Registration process, using UsersWP.

    Would you Please help me do that?

    Needing to hear from you soon.

    Regards

    Plugin Contributor Paolo

    (@paoltaia)

    WordPress already creates a unique ID for each users at registration.

    Create a shortcode using the uwp_get_displayed_user() function and add it to your profile via Form Builder > Profile Tabs

    I asked ChatGPT to do this and it knocked it out of the park:

    1 Install the Code Snippet plugin and create a new snippet with the following code or add it to functions.php of your child theme:

    function output_uwp_user_id() {
        // check if we are on a UsersWP profile page
        if (function_exists('uwp_get_displayed_user')) {
            // get the user being displayed
            $displayed_user = uwp_get_displayed_user();
    
            // if a user is found, return the ID
            if (!empty($displayed_user->ID)) {
                return $displayed_user->ID;
            } else {
                return "No user found.";
            }
        } else {
            // return an error message if we are not on a UsersWP profile page
            return "This shortcode only works on UsersWP profile pages.";
        }
    }
    add_shortcode('uwp_user_id', 'output_uwp_user_id');

    add the shortcode to a new tab or nest the new tab inside an existing tab

    [uwp_user_id]

    I tested it and it works flawlessly.

    Plugin Contributor Paolo

    (@paoltaia)

    Thread Starter gamicord

    (@gamicord)

    Hello Sir,
    Thanks for your reply. It made my day. I am so glad and dancing, and smiling at this answer.

    Now, I don’t want you to see me as Oliver Twist–who is never satisfied.

    So that, while your solution is good, I would like to add a prefixed Text of “RefCode” before the Number.

    So that the Number will appear like this— RefCode: 75

    1.) How do I do that?

    Needing to hear from you soon.

    Regards.

    Plugin Contributor Paolo

    (@paoltaia)

    Where you added the shortcode, write:

    RefCode: [uwp_user_id]

    That’s it.

    If you are enjoying UsersWP, please consider leaving a positive review, it’d help us grow!

    Thanks in advance

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Generating Unique User ID after Registration’ is closed to new replies.