mycred_link

Codex / mycred/core / Shortcodes / mycred_link

Description

This shortcode allows you to award or deduct points from the current user when their click on a link. This shortcode will always generate a link, even if the user viewing it has already clicked on it / reached their limit or if the shortcode is viewed by a user that is logged out. However no points will be paid out unless the user is logged in, are not excluded and have not yet reached the limit you might have set for the “Points for clicking on links” hook.

If you do not set a point amount to award in the shortcode, the amount you set in the hook will be paid out instead.

You can set a limit for how many times a user can gain points for clicking on each individual link. This can either be enforced using the URL you set for the link or using an ID. If you set to enforce a limit using an ID and you do not set an ID in your shortcode, the hook will convert the URL into an ID.

This shortcode uses AJAX to award points. This means that a link will not redirect a user to the targeted URL until the AJAX handler has responded with a result. This in turn can on some sites results in a slight delay from the moment you click on the link until your browser starts loading the URL. This of course only occurs if you do not use the target attribute.

Requires the “Points for clicking on links” hook to be enabled.

Available since version 1.1

Shortcode Attributes

Attribute Type Required Default Description
href string Yes - The URL the link leads to.
amount int or float No - The amount of points to give users to clicking on the link. If not set, the amount you set in the hook will be awarded.
ctype string No MYCRED_DEFAULT_TYPE_KEY The point type to give users. Should not be used if you only have one point type installed.
id string No - Option to set the ID attribute for the anchor.
rel string No - Option to set the ref attribute for the anchor.
class string No - Option to set the class attribute for the anchor.
title string No - Option to set the title attribute for the anchor.
target string No - Option to set the target attribute for the anchor.
style string No - Option to set the style attribute for the anchor.
hreflang string No - Option to set hreflang attribute for the anchor.
media string No - Option to set the media attribute for the anchor.
type string No - Option to set the type attribute for the anchor.
onclick string No - Option to set the onclick attribute for the anchor.

You can only give points to users in the point types you have enabled. If you have a custom point type where the “Points for clicking on links” is not enabled, the user will not receive this type of points.

CSS Styling

a.mycred-points-link { }

Examples

Example 1: Give 1 point for clicking on a link.

[mycred_link amount=1 href="http://www.merovingi.com" target="_blank"]View portfolio[/mycred_link]

Example 2: Give 10 custom point type “coins” for clicking on a link.

[mycred_link amount="10.000" href="http://www.merovingi.com" target="_blank" ctype="coins"]View portfolio[/mycred_link]

Example 3: Give users points based on your hook settings.

[mycred_link href="http://www.merovingi.com"]link title[/mycred_link]

Last edited August 12, 2016