New 'can' and 'cannot' tag

We just added can and cannot tags to snippets. The can and cannot tags check to see if someone has a particular permission.

We just added can and cannot tags to snippets. The can and cannot tags check to see if someone has a particular permission. Now you can do things like …

{% can manage_items %}
	Do something special for people who can manage items.
{% endcan %}

and the opposite …

{% cannot manage_items %}
	Do some thing for people who cannot manage items.
{% endcannot %}

To see what permissions you can have, check the permissions on a role. Currently there are …

  • manage_roles
  • manage_items
  • manage_orders
  • manage_prices
  • manage_site design
  • manage_settings
  • manage_regions
  • manage_contacts
  • manage_billing
  • manage_anything

So how does it know if someone can or cannot do something? Well, the user has to be signed in and they have to belong to a role that has that particular permission.

Another tag that does a similar function that you might like to investigate is the member_of tag. That checks if the currently signed in user belongs to a particular role.

by Craig Sullivan
launch.ly

2 May 2014