We've had a few Shopify administrators selling sensitive products ask whether or not it was possible to allow users to post on their forum or comments sections without leaving their full name — but still use the "use customer accounts" feature.
Behold, there is a way!
Keep in mind, this requires advanced code, and should only be the territory for experienced liquid developers. If you are new to liquid code, be very careful as it's easy to break your site if you don't know what you're doing
It's really important to be careful when editing this code. And anytime you edit code in one of the main Muut files, it's usually better to make a custom version of the file. When you make the custom file your edits will be saved if you ever need to refresh templates or something else strange happens.
So, you might copy the content from the snippet muut-forum.liquid
into a new document named muut-forum-anon.liquid
Once you've made the custom duplicated snippet you'll want to create a new template for the corresponding snippet to call that new document.
In the case of muut-forum.liquid
you'd create a new version page.forum.liquid
The normal file might look something like this
<div class="grid">
<div class="grid-item">
<header>
<h1 class="text-center">{{ page.title }}</h1>
<hr class="hr--small">
</header>
{% comment %} Regular page content goes here. {% endcomment %}
<div class="rte"> {% include "muut-forum" %} </div>
</div>
</div>
So you'd create a new template to include the new snippet. We named ours page.forum-anon.liquid
<div class="grid">
<div class="grid-item">
<header>
<h1 class="text-center">{{ page.title }}</h1>
<hr class="hr--small">
</header>
{% comment %} Regular page content goes here. {% endcomment %}
<div class="rte"> {% include "muut-forum-anon" %} </div>
</div>
</div>
Once you create a new template, be sure to select the new template suffix on your pages section
Other Muut snippets do not have default Muut templates and are simply integrated manually on your existing or new liquid templates. You can find more information on the main Shopify docs.
You'll find the following section in these liquid templates: muut-standalone.liquid
muut-forum.liquid
muut-comments.liquid
and muut-channel.liquid
var muut_current_user = {
id: "{{ customer.id }}",
email: "{{ customer.email }}",
displayname: "{{customer.name }}",
token: "{{ customer.metafields.muut.token }}"
That is the code that controls the "use customer accounts" or Federated ID/SSO section.
The only section you should worry about when anonymizing user accounts is the displayname
section.
Most folks who want to anonymize user accounts, simply want to change things a bit, so the user's full name isn't present. If we take a look at the available customer objects for Shopify there are three notable ones:
customer.first_name
- Shows only the first name
customer.last_name
- Shows only the last name
customer.id
- Shows a unique customer ID number
In the example below, you can see we've opted to use only the first name of our users
```XHTML
var muut_current_user = {
id: "{{ customer.id }}",
email: "{{ customer.email }}",
displayname: "{{customer.first_name }}",
token: "{{ customer.metafields.muut.token }}"
You could also give each person a number with a little flair:
var muut_current_user = {
id: "{{ customer.id }}",
email: "{{ customer.email }}",
displayname: "User #{{customer.id }}",
token: "{{ customer.metafields.muut.token }}"
Or if you want a very confusing page to look at you could just give everyone the exact same display name:
var muut_current_user = {
id: "{{ customer.id }}",
email: "{{ customer.email }}",
displayname: "Happy Customer",
token: "{{ customer.metafields.muut.token }}"
And that's it! That's how to anonymize users in Shopify. :)