In this tutorial I will introduce you to the myCred Ranks add-on. We will set up a few ranks and I will show you how to present ranks for users and how to customize your theme to accommodate ranks via custom templates.
- myCred 1.1 or higher.
- Basic understanding of how WordPress theme template files work.
The myCred Ranks add-on allows you to setup ranks based on how many points a user has. Ranks are custom post types and are edited and created just as posts or pages.
Each rank holds three sets of information: The Ranks Title, The Points Requirement and optionally the Rank “Logo” which is the Featured Image feature in WordPress.
There is no limit to how many ranks you can have, as long as the points requirements does not overlap.
Just as with posts and pages, you can save Ranks as drafts, Publish a rank or Schedule a rank for being published at a later date.
When a rank is “Published”, myCred will run though all of your users and assign those who meet the points requirements to the rank you just created. So draft ranks or scheduled ranks are not assigned until they get published!
While Ranks also support ranks to be set as “Private” it is not recommended. The rank shortcodes that present ranks on your website will only display Public Published ranks! On the other hand, if you use custom theme template files for your ranks, you could technically display “Private” ranks just as posts for those who can see them.
Note that Rank editing and creation requires you to have the same capabilities as when publishing pages. This means that if you are using the default WordPress roles, only Administrators will have access to editing and creating ranks.
To start using Ranks, simply visit the “Add-ons” sub-menu page under “myCred” in your Admin area and enable the “Ranks” add-on.
To change your Ranks settings, visit the “Settings” sub-menu under “myCred” and click on “Ranks” section.
Here you can adjust what features the Rank post type should offer, by default only rank title, point requirement and featured image is enabled but myCred as of 1.1.1 also supports the editor, comments, excerpt or page attributes.
By default, myCred ranks are not public. This means that the only way to see ranks or to list ranks is by using shortcodes. You can however set ranks to be public enabling you to create archives or even custom single layouts in your theme folder. For more information on how to do this, have a look at this tutorial.
You can also select in what order ranks are shown both in the admin area and in front.
By default, myCred will create a rank called “Newbie”. This rank’s points requirement is set to range from 0 to 999999. Before we add a new rank, we start with editing this Newbie rank to suit our needs. Since this will be our lowest, default rank, we will leave the minimum points requirement at zero but we will change the maximum to 99.
Furthermore, in this tutorial, the newbie rank will have no logo, of course you can have one if you want.
Adjusting the default Rank
Once we have changed our maximum point requirement we click “Update” to save our settings. When our changes are saved, we click on “Add New” button next to the “Edit Rank” title.
We will call our new rank “Junior” and this ranks point requirement will run from a minimum of 100 to a maximum of 999.
You can of course rename the default rank to a name or even delete it and just start fresh.
For this rank, we are going to add a logo. Just like any other Featured Image, we can either upload an image to use or select one from your Media Library. When you have found your image, simply select it and click “Set Featured Image”. Once your image is visible in your “Featured Image” metabox, we click “Publish”.
Rince and repeat
Now that we have created our new rank, we can create as many ranks as we need. Simply repeat the above steps for each rank until you’re satisfied.
There are three instances when myCred assigns a rank:
- When a rank is published.
- When users signup and become members on your website.
- When a user gains or loses points.
This means that myCred will assign roles for your users automatically without the need for you to do it individually. This also means that the only way for you to manually adjust a users rank is to award / deduct points form the user.
Besides showing ranks though your themes template files, which we will look at in a second, you can also show your users ranks though the myCred Balance widget or through the use of custom shortcodes. But lets start with the widget.
myCred Balance Widget
When editing the balance widget, you get the option to set the “Layout” for how the balance is presented. You could include a users rank here by using the template tag
%rank% to show the users rank title or
%rank_logo% to show the rank logo.
Depending on your theme, you might need to add some custom CSS styling to the image or title suit your website layout.
myCred Ranks comes with three different shortcodes that you can place in your page or post content.
Use this shortcode to show a specific users rank or by default, the current logged in users rank. Consult the codex for all available options.
Use this shortcode to display users of a specific rank. Consult the codex for all available options.
Use this shortcode to show users of each and ever published rank in order. Consult the codex for all available options.
That is the end of this introductory tutorial. If you have any questions feel free to post them below.
Feel free to post your questions or remarks below.