Adding labels to members on signup isn't working

  • Summary: When I add a “data-members-label” field to a form, I expect the member to be assigned the submitted label. Instead, the label is added to the dropdown list of available labels in the Members area of the Ghost dashboard, but the member is not actually assigned the label.

  • URL: The site is currently private so I cannot provide a URL at this time.

  • Ghost version: 4.1.2

  • How was Ghost installed and configured? Hosted version.

  • What Node version, database, OS & browser are you using? Whatever the hosted version is using.

  • What errors or information do you see in the console? None.

  • What steps could someone else take to reproduce the issue you’re having?

  1. Add a form to a frontend template and include a “label” field. Something like:
    <form data-members-form='subscribe'>
    <input data-members-label type='checkbox' value='mylabel'>
    <!-- Or: <input data-members-label type='hidden' value='mylabel'> -->
    <input type='email' name='email'>
    <button type='submit'>Subscribe</button>
    </form>
  2. As a logged-out user (i.e. in an incognito window), click the checkbox and add a valid email address. Submit the form.
  3. Click the link in the activation email you receive at the email address from #2.
  4. Go to the members area of the Ghost dashboard (/ghost/#/members) and select the newly-created member.
  5. Observe the “Labels” field. Expected result: the label “mylabel” should be present. Observed result: no labels are present; the label “mylabel” is, however, available as an option in the dropdown.

What do I need to change to get the label to be correctly assigned to the new member?

1 Like
<input data-members-label type='checkbox' value='mylabel'>
<!-- Or: <input data-members-label type='hidden' value='mylabel'> -->

Which one of these are you using? The commented line is what our docs recommend, and should work to add a label - are you saying that doesn’t work?

Not sure about the checkbox usage - haven’t seen that use-case before

I have tried both (and a variety of other solutions, like adding additional attributes, i.e. name=“label” and such) with no success.

Here are some screenshots to help illustrate. After a new member is created, this is what I see:

Note the empty label field. If I click on the field, I see a list of available labels, but none of those labels are applied to the member:

What I expect to see is the label correctly and automatically applied to the member, like so:

1 Like

@mrwilson We have been able to reproduce the bug and will be pushing a fix soon for this.

3 Likes

I have the exact same bug (label created in the dropdown but not applied to the member created). In weeks, haven’t been able to have this feature to work once. Good to hear a fix is coming soon!

Thank you, @rishabhgarg. I look forward to that fix! Let me know if I can help in any way.

I also notice that if the value of the hidden label is some attribute (like primary_tag) and the value is null (no tags assigned), then when the user clicks to confirm subscription, the Portal says error…I would think this is an unexpected behaviour.

Hi @rishabhgarg, do you happen to know in which version this bugfix might appear? My client has asked me for an update. I haven’t been in the Ghost ecosystem for very long, so I’m still learning about things like your product release schedule.

Update: The fix for this will be out in next release of Ghost - v4.5.0 - which will be released this week.

3 Likes

Thank you, Rishabh. One great addition would be the ability to email subsets of users based on tags associated with them. Just a thought.

1 Like

The fix is live in Ghost v4.5.0, please upgrade

@Davis_Hunt The latest release also allows you to filter newsletter recipients based on labels. :slight_smile:

Hi guys,

maybe some of you could advise? For me, the labels also don’t work. I have it in the dropdown of the labels in the members but it’s not giving it the proper label to the member, tried both codes.

Please see my code below, I’m using the form from my theme. Not sure what I’m doing wrong.

       <form data-members-form="subscribe" class="c-subscribe-form">
  <div class="form-group">
    <label for="subscribe-email-footer" class="u-hidden-visually">Your email address</label>
    <input data-members-label type="hidden" value="DPC'>
    <input type="email" name="email" class="c-subscribe-form__input" id="subscribe-email-footer" placeholder="Your email address" data-members-email="">
    <button type="submit" value="Subscribe" class="c-btn c-btn--action c-subscribe-form__btn">Subscribe</button>
  </div>

  <div class="u-alert u-alert--success u-mt-16">Please check your inbox and click the link to confirm your subscription.</div>
  <div class="u-alert u-alert--invalid u-mt-16">Please enter a valid email address!</div>
  <div class="u-alert u-alert--error u-mt-16">An error occurred, please try again later.</div>
</form>

Thank you in advance! :slight_smile:

Hey @PixelzFairy , which version of Ghost you are running ? The fix for this landed with release of 4.5, can you try again after updating to latest version of Ghost and see if you can still reproduce this behaviour.

Hey @rishabhgarg , I’m on Ghost Pro, so the latest 4.6.3

@PixelzFairy I am unable to reproduce the issue with the code you pasted, its able to create and assign label correctly. If you still run into any problems I’d suggest you reach out to Ghost Pro support directly :slight_smile:

Can you allow the user to select multiple labels using checkboxes?

I can confirm this is still broken.

As of now the HTTP request contains all of the labels, not just the checked ones.

This is because Portal doesn’t follow regular form behavior, and takes the value attribute of the checkboxes with no regard to its checked status.

I will open a GitHub issue for this soon.

Did you open a GitHub issue for this?

I am experiencing the same problem, all labels are selected and not just the selected ones.

Is this something that will be fixed? No one seems to be responding about this issue.