Casper Theme Subscription Form Customization

So I use the members’ feature to collect subscribers and I want to segment the subscribers by labels. I know I can go into the dashboard and add them one at a time, but I want to customize the subscription form altogether, I want to add 3 little checkboxes under the form that says “click all that apply” so when a user subscribes they can choose what category(s) they want to subscribe too.

The categories on my website are Art, Tech, Business. So I would want 3 checkboxes one for each category/label, so when they subscribe they get the right label/labels.

I hope this makes sense. Could really use some help!

1 Like

Any help on this?

Hey @IndustryExperts :wave:

You can apply Member labels in the signup forms using hidden input fields like so:

<form data-members-form="subscribe">

  <input data-members-label type="hidden" value="Early Adopters" />

  <input data-members-email type="email" required="true"/>
  <button type="submit">Subscribe</button>

When people use this form to sign up they’ll have the label “Early Adopters” applied. More info can be found here:

Hope this helps! :blush:

Well, not really. Because my subscription form shows on the bottom of every post. I want my subscribers to be subscribed based on what post they are reading. For example if they are reading a post in my art category, I want them labeled art, when they subscribe, but if they are reading a tech post in my tech category, I want them labeled tech when they subscribe.

Is there a way to apply the labels based on the tag of the post they are reading?

Presuming those are primary tags I imagine you should be able to do something like this
<input data-members-label type="hidden" value="{{primary_tag}}" />

I tried adding the above code, and when I tested a subscriber they still did not get labeled at all.

If you haven’t, maybe try it hard coded first (like in the original example) to see if that works at all?

And you’ll want to make sure the input element you added is inside the form tags.

I tried that, I have tried adding different codes to different places, and seems like maybe its not working? Maybe I am not saving the files correctly? But I open the post.hbs file add the code click save, and re upload the theme and nothing seems to be working

That does sound like there could be a bug to me but I’m not official ghost staff, just trying to be helpful where I can. :smile: If you aren’t already you should probably be developing your theme locally like so:
Local Install

It makes it easier to test changes quickly without having to re-upload your theme every time and without affecting your published site.

On the debug side - have you already made the label you’re trying to add on the members panel? You might need to make sure it exists there before it can be applied via the form.

Here is an image of my theme code for the subscription form to always render, what code do I add and where to get the labels applied to subscribers based on primary tag I am guessing?

Ah, that’s not the file you want to add the input to, as it turns out. You’re going to need to find the file called subscribe-form.hbs. Your post file is referencing that (By having the line {{> subscribe-form}}) to show the form, so that’s the file you’re going to need to add the input to. It’ll likely be under a folder called partials.


Okay here is the right file, wheree do I add the input?

Line 4. Right after <div class="form-group"> and right before <input class="subscribe-email" ... />

Okay, I did everything correctly, and when I tested a subscriber they still did not get labeled

Did you already have the label added in your admin panel beforehand?

Under admin > members there should be a labels dropdown here:

I want to know if the label you’re trying to add is already in that dropdown. If not, try using the + Add Label button to add it and then test out your subscribe form again.

I added the labels before hand. I have 3 labels already created, Art, Tech, Business

Mind taking another screenshot of your subscribe-form.hbs with the new input in it for me?
I’m sure you added it fine but something might jump out at me if I can stare at it.

I feel a little dumb. Instead of {{primary_tag}} you’ll want to do {{}}. I totally forgot that just doing primary_tag doesn’t actually get you the right thing. That’s my fault.

Okay, once I do this, is there a way to send emails to only one label?