Out of the box, Locksmith automatically protects all content between the header and footer, for everything covered by your locks.

Sometimes this can be too aggressive - you might want to allow visitors to preview your products without being able to see pricing, for example. Or, you might want to protect just the checkout button of your cart.

Locksmith comes with an advanced manual mode that allows for this sort of thing. It disables Locksmith's full-page protection, stepping aside so that some custom code in your theme can take responsibility for hiding part of your content.

Note: If a particular piece of content has multiple locks in play (for example, if the customer is viewing a product that is a part of several locked collections), manual lock will only work if all applicable locks have manual mode enabled.

Purpose-specific guides

And now, a more general guide:

Because each theme is a bit different, manual locking does require manual coding. If you install a new theme down the road, these changes will need to be re-applied.

Enabling manual mode

Before proceeding, make sure that your theme is set up for manual locking. Use the next sections of this guide to get the necessary changes in place.

  1. Log in at uselocksmith.com, then click on the lock for which you'd like to use manual mode.
  2. Click the "Advanced Settings" button (just above the Save Lock button), and tick the checkbox for "Enable manual locking". Then, hit save.

That's it! Locksmith will hold off on its full-page protection with this enabled, and allow your custom code to enforce protection.

Updating your theme for manual locking

Manual locking leverages Liquid variables to empower you to render content however you'd like, based on Locksmith's permissions.

Locksmith's variables are loaded via the locksmith-variables snippet. It can be included two ways:

  1. {% include 'locksmith-variables' %}  - in this mode, Locksmith will autodetect the applicable locks for the current url, and set up its access variables accordingly.
  2. {% include 'locksmith-variables', locksmith_scope: foobar %}  - in this mode, you specify the exact object that Locksmith should base its access decisions upon. Use this if you need to load up Locksmith's variables based on the cart, or a certain product, or some other Liquid variable, regardless of what url the user is on

After loading the Locksmith variables, wrap the code you'd like to conditionally hide like this:

{% if locksmith_access_granted %}
  You've got access!
{% endif %}

Variable reference

There are four variables, all told, that you can use to make decisions in your Liquid code:

  • locksmith_locked  (is there a lock active for this content?)
  • locksmith_access_granted (should the visitor be allowed to access this content?)
  • locksmith_access_denied  (should the visitor be prevented from accessing this content?)
  • locksmith_manual_lock  (is manual mode on for all locks active for this content?)

All four of these will be given the value true or false, as appropriate - feel free to use these variables however you need them.

Triggering passcode or Mailchimp forms

Important note: this combination is only available in Locksmith v4; Locksmith v5 does not yet support manual locking with server keys, including the passcode key. Keep an eye on the release notes for updates.

If you're using manual locking in conjunction with a passcode or Mailchimp key, Locksmith won't display the lock form by itself, since it's allowing you to manage protection completely.

Because of this, you'll want to add a way for customers to submit their input. Try adding this code to your template to create a button that, when clicked, brings up the Locksmith form:

<button type="button" class="locksmith-manual-trigger">
  Click to enter
</button>
Did this answer your question?