Title: User Awards
Author: kwmartin
Published: <strong>May 24, 2019</strong>
Last modified: July 24, 2019

---

Search plugins

This plugin **hasn’t been tested with the latest 3 major releases of WordPress**.
It may no longer be maintained or supported and may have compatibility issues when
used with more recent versions of WordPress.

![](https://ps.w.org/user-awards/assets/icon-256x256.png?rev=2123539)

# User Awards

 By [kwmartin](https://profiles.wordpress.org/kwmartin/)

[Download](https://downloads.wordpress.org/plugin/user-awards.0.1.1.zip)

 * [Details](https://pcd.wordpress.org/plugins/user-awards/#description)
 * [Reviews](https://pcd.wordpress.org/plugins/user-awards/#reviews)
 *  [Installation](https://pcd.wordpress.org/plugins/user-awards/#installation)
 * [Development](https://pcd.wordpress.org/plugins/user-awards/#developers)

 [Support](https://wordpress.org/support/plugin/user-awards/)

## Description

Activating this plugin now means that you are able to award users for specific actions
that they take.

**NOTE**: Currently this only works for actions that update or add to user meta 
values.

At a basic level, the following happens when you activate this plugin:

 * Awards _custom post type_ is added to the administration window. Regular post
   type window but with a few additional meta boxes that provide access to the core
   behavior of this plugin.
 * A new table is created under the name of `{wpdb_prefix}user_awards`. This contains
   all award assignment references to users. The _User Awards_ sub-menu provides
   an interface to help perform administrative actions on the table.

There is also a `User Awards` sub-menu which gives a tabular view of all the awards
that are assigned to users. This is accessible from the `Awards` admin menu in your
WordPress administration area.

### Usage

Understanding the different actions you can take in each available window is key
to having this plugin work for you.

### Award List Window

This window displays all of the specific “Award” post types.

There are two different bulk actions available to you:

 * **Bulk Assign** – Assign multiple awards to a user
 * **Bulk Give** – Give multiple awards to a user

### New Award / Edit Award Window

These administration windows have three meta boxes associated with them. Below are
descriptions of each metabox and why it is included.

### Awards Trigger

_Text Input_. Accepts an **awards trigger string**, which will describe the behavior
of how an award will be assigned to users. Documentation for the awards trigger 
is shown below.

#### Example

You have a membership blog site, and because you’re a nice person, you want to award
your members for being engaged with your site and liking at least ten blog posts!

A previous developer implemented a like button on each of your site’s blog posts
that increments a `post_likes` _user\_meta_ value on the user that clicks it (e.
g. If a member likes 3 blog posts, they will have a `post_likes` meta value of `
3`).

We’ve decided to name our award the “User Engagement” award. In order to _assign_
it to a member based on the prerequisites, you would put something like this in 
the “Awards Trigger” input.

    ```
    CURRENT_USER_META ASSIGNED WHERE key=post_likes EQ 10
    ```

This string tells the award to assign itself to the user if the `post_likes` value
of the current user’s meta was updated or created to equal a value of `10`.

### Auto-Give Award

_Checkbox input_. Check this box to automatically have the award be _given_ to a
user when it would originally be assigned.

### Apply/Give Award To User

_Select Input combined with a checkbox input_. Select a user from your member list
to either assign/give an award by clicking on the _Assign_ submit button.

### User Awards Window

This window allows administrators to **physically see and update** the status of
all of the awards that are assigned to users.

This window will allow you to perform the following actions:

 * Singular/Bulk remove awards from members
 * Singular give awards to members
 * Edit Awards

### Documentation

### Awards Trigger Syntax

Explanation of each of the items that make up our trigger string, with accepted 
values of each listed under.

 * [ entity ] — Used to scope your awards trigger to a specific action.
    - CURRENT_USER_META — Consider the meta value of the current user
 * [ trigger_type ] — Type of action that is performed to the current entity.
    - UPDATED — When entity value is updated (Listens to calls of the update_user_meta()
      function)
    - CREATED — When entity value is created (Listens to calls of the add_user_meta()
      function)
    - ASSIGNED — Listens to calls of both the update_user_meta() and add_user_meta()
      function.
    - ~EXCLUDED~ — Not Implemented
 * [ trigger ] – Made up of three separate values itself, [ descriptor ] [ operator][
   control ]
    - [ descriptor ]
       * [ entity_type ] = [ value ] ex: key = hours
    - [ operator ]
       * GT – greater than
       * LT – less than
       * EQ – equal to
       * GTEQ – greater than equal to
       * LTEQ – less than equal to
    - [ control ]
       * Value used to compare against. e.g. 2
       * _NOTE_: The control _can also be a string_, but in order for this to work,
         you must use the EQ operator, as shown above.

EXAMPLE:

    ```
    CURRENT_USER_META UPDATED WHERE key=total_hours GT 600
    ```

This example creates a wp action handler that only applies when a user’s meta tags
are updated.
 In the handler, we will compare the meta tag being updated to the 
given comparitors in the [ trigger ]. i.e. we will look for a meta tag of the current
user that is labeled “total_hours” and check to see if the value is greater than
600. If that’s the case then the award will be assigned. If not then nothing happens.

### $UserAward Global Object

The awards trigger syntax, while nice, is too limited in its current form. Our plugin
provides a global _$UserAward_ variable that allows developers to interact with 
the core API of the plugin in order to award items through methods that simply are
not possible / too complex.

You will find documentation and usage for functions available to you below.

global $UserAward;

/**
 * Check to see if a user already has a specific award * @param int $user_id–
WPUser_ID * @param int $award_id – UserAward_ID (Post ID) * @return bool Whether
or not this user has an award with the current award id */ $UserAwards->UserHasAward(
$user_id, $award_id );

/**
 * Assigns multiple awards to users using AssignAward * @param int $user_id –
WPUser_ID * @param array $award_ids – Array of UserAward_IDs (Post ID) * @return
bool – True if awards were assigned, false if there was an error with assigning 
awards */ $UserAwards->AssignAwards( $user_id, $award_ids );

/**
 * Function that marks an award as assigned to a user. * We insert a new record
into our awards table that relates the award to the user. * * We do check to see
if there is an auto-assignment of the award before we finish up our function though.**
@param int $user_id – ID of the user that we are “awarding” the award to * @param
int $award_id – ID of the award that we are “awarding” * @return bool – True if 
award was assigned, * False if: * – User already has that award * – Error with assigning
our award */ $UserAwards->AssignAward( $user_id, $award_id );

/**
 * Give multiple awards to users using GiveAward(). * @param int $user_id – 
WPUser_ID * @param array $award_ids – Array of UserAward_IDs (Post ID) * @return
bool – True if awards were given, false if there was an error with giving awards*/
$UserAwards->GiveAwards( $user_id, $award_ids );

/**
 * Function that will mark an award as given to a user, * which essentially 
means that we mark the “date_given” time with * an actual date. * * Returns the 
return value of a `db->update` call * * @param int $user_id – ID of the user that
we are “awarding” the award to * @param int $award_id – ID of the award that we 
are “awarding” * @return mixed – Return value of a $wpdb->update() call */ $UserAwards-
>GiveAward( $user_id, $award_id );

/**
 * Removes awards from our database. * If “$award_id” is null, then we are going
to delete everything in the database with the specific “$user_id” * * @param int
$user_id – ID of the user that we are “awarding” the award to * @param int $award_id–
ID of the award that we are “awarding” * @return mixed – Return the value of a $
wpdb->delete() call */ $UserAwards->RemoveUserAward( $user_id, $award_id = NULL );

/**
 * Function that grabs as many awards assigned to the user as we can based on
the parameters given. * For example, if just a user_id is supplied, then we will
return all of the awards with that user_id. * If an award_id is supplied along with
our user_id then we will probably get only one award. Hopefully * * @param int $
user_id – ID of the user that we are “awarding” the award to * @param int $award_id–
ID of the award that we are “awarding” * @return mixed – Returnes the value of a
$wpdb->get_results() call */ $UserAwards->GetUserAward( $user_id, $award_id = NULL);

### Attribution

This plugin’s icon is not an original piece of work. It was made by [**Freepik** from Flaticon.com](https://pcd.wordpress.org/plugins/user-awards/www.flaticon.com?output_format=md)

## Screenshots

 * [[
 * Award List Window. Shows the awards that are available to give to users.
 * [[
 * New/Edit Award Window #1
 * [[
 * New/Edit Award Window #2
 * [[
 * User Awards window. Shows any awards that are assigned to users.

## Installation

 1. Upload the plugin files to the `/wp-content/plugins/user-awards` directory install
    the plugin through the WordPress plugins screen directly
 2. Activate the plugin through the
     This section describes how to install the plugin
    and get it working.
 3. Activate the plugin through the ‘Plugins’ screen in WordPress. You should be notified
    if the plugin activation was successful.
 4. Click on the `Awards` menu item on the administrator sidebar in order to interact
    with the User Awards plugin administration actions.

## FAQ

No frequently asked questions are known at this time.

## Reviews

There are no reviews for this plugin.

## Contributors & Developers

“User Awards” is open source software. The following people have contributed to 
this plugin.

Contributors

 *   [ kwmartin ](https://profiles.wordpress.org/kwmartin/)

[Translate “User Awards” into your language.](https://translate.wordpress.org/projects/wp-plugins/user-awards)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/user-awards/), check
out the [SVN repository](https://plugins.svn.wordpress.org/user-awards/), or subscribe
to the [development log](https://plugins.trac.wordpress.org/log/user-awards/) by
[RSS](https://plugins.trac.wordpress.org/log/user-awards/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### Version 0.0.2

Updating readme.txt

#### Version 0.0.1

Initial version of the plugin.

## Meta

 *  Version **0.1.1**
 *  Last updated **7 years ago**
 *  Active installations **Fewer than 10**
 *  WordPress version ** 5.1.1 or higher **
 *  Tested up to **5.2.24**
 *  PHP version ** 5.6 or higher **
 *  Language
 * [English (US)](https://wordpress.org/plugins/user-awards/)
 * Tags
 * [Awards](https://pcd.wordpress.org/plugins/tags/awards/)[user engagement](https://pcd.wordpress.org/plugins/tags/user-engagement/)
 *  [Advanced View](https://pcd.wordpress.org/plugins/user-awards/advanced/)

## Ratings

No reviews have been submitted yet.

[Add my review](https://wordpress.org/support/plugin/user-awards/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/user-awards/reviews/)

## Contributors

 *   [ kwmartin ](https://profiles.wordpress.org/kwmartin/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/user-awards/)

## Donate

Would you like to support the advancement of this plugin?

 [ Donate to this plugin ](http://N/A)