Database model

As of versions 2.0.x, Achievements has three custom database tables: achievements, achievements_actions and achievements_unlocked. The main table is wp_achievements which stores all of the information that you enter when you create an Achievement on your website.

There was a graphic here showing the table relationships, but it got lost when I changed server hosts. I’ll re-do the graphic soon.

wp_achievements

action_id maps to the achievements_actions table’s id field. If this value is -1, it means the Achievements is an “award” and not an “event” type.

picture_id maps to WordPress’ posts table. It should only ever refer to a record with a post_type of “attachment.”

action_count is how many times must the event is required to occurs before the Achievement is unlocked. If this field is 0, the Achievement will unlock the first time, but for all successive unlocks, points will still be awarded but the Achievement won’t be unlocked again.

is_active takes three values 0 (disabled), 1 (active) and 2 (active but hidden).

site_id only matters if you are running Achievements on multisite. If you are, the Achievement’s action needs to occur on the site with the same ID. If this field is 0, then the action can occur on any site.

group_id only applies to some of the group actions. For example, the “post in a group’s activity stream” action — the action needs to occur in a group with the same ID. If this field is 0, then the action can occur on any site.

wp_achievements_actions

An Achievement has one action, and this table contains those actions. The name column must match the name of the first argument of the relevant do_action() call.

is_group_action is used in conjunction with the checks as described in the wp_achievements table’s group_id section above, and accepts either 0 (false) or 1 (true).

wp_achievements_unlocked

When a user meets the requirements of an active Achievement, they are said to have “unlocked” it. This table contains records of who has unlocked which Achievements, when.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s