How can I edit members-only content without login issues?

Solved

How can I edit members-only content without login issues?

PartPurple
Shopify Partner
21 1 1

Hey y'all! This is a doozy, and I hope I can adequately explain the situation.

 

Our shop has a membership subscription we'll call X. When an X membership is purchased, their customer tags are automatically and immediately updated to flag them for access. This tag grants them access to members-only content, like a blog, product collection, and free downloads.

 

I designed a way to shunt members and non-members to the appropriate content. When they visit the X page on the site and they are not a member, they see the x-members-info Section content. If they're tagged appropriately and haven't canceled their membership, they get to see the x-members Section content.

 

Here is the code on page.x.liquid:

{% if customer.tags contains 'X Member' %}
	{% unless customer.tags contains 'X Canceled' %}
		{% section 'x-members' %}
	{% else %}
		{% section 'x-members-info' %}
	{% endunless %}
{% else %}
	{% section 'x-members-info' %}
{% endif %}

(This method is also used for the members-only blog and articles, collection and products, and downloads.)

 

The way we usually edit the content in either Section is to open the Theme Customizer and change the x-members-info Section while logged out as a customer, then login with our flagged customer accounts within the Customizer and edit x-members Section content. This has worked great for years.

 

The problem is that, on occasion, when we try to login within the Customizer to change the members-only content, we get redirected right back to the login form. No login = no editing. This has happened off and on for the past year or more with no rhyme or reason. It always seems to resolve itself after a while, but only after much hand-wringing and gnashing of teeth. We've talked with Shopify as well as the theme creators with no real insight from either of them. Our customers are not affected by this issue.

 

It happened again today. I'm now on the hook:

  • Find another way for us to change the members-only content in the Customizer
  • that bypasses the login process
  • while maintaining restricted customer access.

I thought about putting the Sections on their own Pages and using page.x.liquid to redirect to those Pages, but looks like I can only do that with JS, and more importantly, I think it would give unlimited access to anyone who knows the URL of the x-members Page. If we do a tag/flag check on the x-members Page to restrict access, we're back to our login problem.

 

Any thoughts y'all have would be greatly appreciated. I need brainstorming from people who haven't been staring at it as long as I have. TYIA!

Accepted Solution (1)

PartPurple
Shopify Partner
21 1 1

This is an accepted solution.

I figured out a solution, in case anyone needs something similar in the future. It was ridiculously simple once I thought about it. You will need to go to Theme > Edit Code, but these are all new Templates and Pages and you will not have to dig into any existing Theme files for editing.

 

You'll need to create two Templates:

1. page.x-admin-info.liquid:

 

{% section 'x-info' %}

 

** This Section name MUST be the same as the "live" Section you wish to edit.

 

2. page.x-admin-members.liquid:

 

{% section 'x-members' %}

 

** This Section name MUST be the same as the "live" Section you wish to edit.

 

Back out of Edit Code and create two Pages (Online Store > Pages) and assign them each their own Template. Save them but do not publish them.

  1. "X Admin Info" uses x-admin-info
  2. "X Admin Members" uses x-admin-members

** It is very important that you use the exact same Section names as the "live" Sections. When you edit the info on these "admin" pages and Save your changes, you will be updating the info customers can see in your shop.

 

Now you can access x-admin-info and x-admin-members via the drop-down menu at the top of your Theme Customizer screen, bypassing the tag/flag check. Since the pages aren't published, accessing them from your shop will throw a 404 error; they can only be accessed in the Customizer.

 

One solution I considered includes this code to check whether or not the page is accessed from within the Customizer. It may come in handy for somebody!

 

{% assign string = 'myshopify' %}

{% if request.host contains string %}  
    {% section 'x-admin' %}  
{% else %}  
    {% if customer.tags contains 'X Member' %}    
    	{% unless customer.tags contains 'X Canceled' %}          
            {% section 'x-members' %}    
    	{% else %}          
            {% section 'x-info' %}    
    	{% endunless %}    
    {% else %}      
        {% section 'x-info' %}    
    {% endif %}
{% endif %}

 

 

View solution in original post

Reply 1 (1)

PartPurple
Shopify Partner
21 1 1

This is an accepted solution.

I figured out a solution, in case anyone needs something similar in the future. It was ridiculously simple once I thought about it. You will need to go to Theme > Edit Code, but these are all new Templates and Pages and you will not have to dig into any existing Theme files for editing.

 

You'll need to create two Templates:

1. page.x-admin-info.liquid:

 

{% section 'x-info' %}

 

** This Section name MUST be the same as the "live" Section you wish to edit.

 

2. page.x-admin-members.liquid:

 

{% section 'x-members' %}

 

** This Section name MUST be the same as the "live" Section you wish to edit.

 

Back out of Edit Code and create two Pages (Online Store > Pages) and assign them each their own Template. Save them but do not publish them.

  1. "X Admin Info" uses x-admin-info
  2. "X Admin Members" uses x-admin-members

** It is very important that you use the exact same Section names as the "live" Sections. When you edit the info on these "admin" pages and Save your changes, you will be updating the info customers can see in your shop.

 

Now you can access x-admin-info and x-admin-members via the drop-down menu at the top of your Theme Customizer screen, bypassing the tag/flag check. Since the pages aren't published, accessing them from your shop will throw a 404 error; they can only be accessed in the Customizer.

 

One solution I considered includes this code to check whether or not the page is accessed from within the Customizer. It may come in handy for somebody!

 

{% assign string = 'myshopify' %}

{% if request.host contains string %}  
    {% section 'x-admin' %}  
{% else %}  
    {% if customer.tags contains 'X Member' %}    
    	{% unless customer.tags contains 'X Canceled' %}          
            {% section 'x-members' %}    
    	{% else %}          
            {% section 'x-info' %}    
    	{% endunless %}    
    {% else %}      
        {% section 'x-info' %}    
    {% endif %}
{% endif %}