Can you change a key’s value for a specific user by the user visiting a URL?

[ad_1]

Let’s say users could sign up for a free account on a website and the default user account comes with a custom field labeled “User Credits”.

Then, a user can run around a convention space with their phone and when the user scans a QR code on a sign, they have 10 Credits added to their account or maybe it subtracts 50 Credits and adds 1 Gold.

What kind of functionality do I need to add to set up something like this?

[ad_2]
1 Comment
  1. It’s fairly straightforward. Setup an action hook on say wp_head and in that hooked function:

    1. Check if the current page is a bonus credits page.
    2. Check the user meta for whether they received a bonus for this page (to prevent multiple bonuses)
    3. If not, update the ‘credits’ user meta field with the current bonus, AND
    4. Update the user meta to record that they got the bonus for this page.

    ACF can create custom fields for users so that you can see the result.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer