• Resolved rauvas

    (@rauvas)


    Hello, we want to use a QR short code for the Ultimate Membership Welcome message template. When each member physically comes to our store and scans the QR code, we will access the user information. However, short codes do not work in Ultimate Membership message templates. How can we do this in Ultimate Member or does it have this feature without the need for another intermediary QR plugin?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter rauvas

    (@rauvas)

    We did the following steps before the Dynamic QR Code Generator plugin. In short, short codes do not work in ultimate member.

    We conducted a study on QR on the https://dijitalinsaatzirvesi.com/ website. In this study, the member will receive a welcome message after signing up and a QR containing the user's information will be created in this message. The QR code is created for every membership, there is no problem here. The problem is that when the QR code is scanned, the [qr_url] short code used in the e-mail template does not turn into a real URL. Instead, the short code appears as [qr_url]. Therefore, the link required to display the user information does not work. When the QR code is scanned, the [qr_url] short code needs to be dynamically converted into a URL. This URL should contain the user's private token and should work in the format https://sitem.com/check-user?token=<token>. In this way, the browser should be directed to the page that will display the user information correctly.

    As a result, is there a restriction by your server? I would be glad if you could help me.

    Actions taken

    1-The following codes were added to the function.php theme file on the WordPress website

    // Create a unique token during user registration
    add_action(user_register, function($user_id) {
    $token = bin2hex(random_bytes(16)) // Create a unique token
    update_user_meta($user_id, qr_token, $token) // Save to user meta information
    })

    // [qr_url] short code for Ultimate Member
    add_filter(um_email_tags, function($tags) {
    $tags[qr_url] = function($user_id) {
    $token = get_user_meta($user_id, qr_token, true) // Get the user token
    if (!$token) {
    return Token not found. // Return error if token is not available
    }
    return site_url(/check-user?token= . $token) // Create unique URL
    }
    return $tags
    })

    // Show user information on /check-user page
    add_shortcode(check_user, function() {
    $token = isset($_GET[token]) ? sanitize_text_field($_GET[token]) :
    if (!$token) {
    return Invalid or missing token. // Return error if token is missing
    }

    // Find user by token
    $user_query = new WP_User_Query([
    meta_key => qr_token,
    meta_value => $token,
    number => 1,
    ])

    $users = $user_query->get_results()
    if (empty($users)) {
    return User not found. // Return error if token does not match
    }

    $user = $users[0]
    return <h2>User Information</h2> .
    <p>Name: . esc_html($user->display_name) . </p> .
    <p>Email: . esc_html($user->user_email) . </p>
    })

    2- The following code has been added to the Ultimate member welcome template

    <p>Scan this QR code to verify your membership:</p>
    <img src="https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=[qr_url]" alt="QR Code">
    <p>Alternatively, you can click this link: <a href="[qr_url]">[qr_url]</a></p>

    3- /check-user page has been created. [check_user] short code has been added.
    Plugin Support andrewshu

    (@andrewshu)

    Hello @rauvas

    Sorry, but customizations are not included in our support.

    Regards.

    Plugin Support andrewshu

    (@andrewshu)

    Hi @rauvas

    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 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.