Issue with {{@member.paid}} helper (404 displayed to paid members)

Hey guys,

I’m having trouble figuring out why my /account/ page doesn’t get display properly to paid members. Namely, I use a very similar structure to what is used in Lyra.

{{#if @member.paid}}

custom message for paid members

{{else if @member}}

custom message for non-paid members

{{else}}

{{/if}}

The problem is that while non-paid members see the correct version of the page, the paid members get a 404 error.

When it comes to the routes file, it also follows a simple flow of:
/subscribe/: members/signup
/signin/: members/signin
/account/: members/account

I’ve tried changing the routes file, applying different flow to if/else if helper but nothing seems to work.
Would appreciate any solutions or ways to try them out. Thanks!

The conditions seem to be fine and should work, but the error could come from what you have inside the paid member block. Maybe you can share that part of the code?

@bironthemes
Sure thing, that’s pretty much all of the code with “blurred” confidential info.

{!< ../default}}
<div class='o-wrapper'>
{{#if @member.paid}}
<div class='c-archive'>
<div class='o-grid'>
  <div class='o-grid__col o-grid__col--center o-grid__col--4-4-s o-grid__col--3-4-m o-grid__col--2-4-l'>
    <h1 class='c-archive__title'>XXX</h1>
    {{#foreach @member.subscriptions}}
    {{#if cancel_at_period_end}}
      <p class='c-archive__description u-color-error'>XXX{{date current_period_end format="DD.MMM.YYYY"}}</p>
    {{else}}
      <p class='c-archive__description'>XXX</p>
      <p class='c-archive__description'>XXX</p>
    {{/if}}
    {{/foreach}}
  </div>
</div>
</div>

<div class='o-grid'>
<div class='o-grid__col o-grid__col--center o-grid__col--4-4-s o-grid__col--3-4-m o-grid__col--2-4-l'>
  {{#foreach @member.subscriptions}}
    <div class='o-grid u-mb-16'>
      <div class='o-grid__col o-grid__col--4-4-s o-grid__col--2-4-m o-grid__col--2-4-l u-mb-16'>
        <label class='u-type-uppercase u-block u-type-600 u-type-sm'>{XXX</label>
          <span class='u-type-sm'>{{@member.email}}</span>
      </div>
      <div class='o-grid__col o-grid__col--4-4-s o-grid__col--2-4-m o-grid__col--2-4-l'>
        <label class='u-type-uppercase u-block u-type-600 u-type-sm'>{{t 'Your plan' }}</label>
        <span class='u-type-sm'>{{ price currency=currency }}{{ price plan.amount }} {{ plan.currency }} / {{ plan.interval }}</span>
      </div>
    </div>

    <div class='o-grid'>
      <div class='o-grid__col o-grid__col--4-4-s o-grid__col--2-4-m o-grid__col--2-4-l u-mb-16'>
        <label class='u-type-uppercase u-block u-type-600 u-type-sm'>{{t 'Card' }}</label>
        <span class='u-type-sm'>**** **** **** {{ default_payment_card_last4 }}</span>
      </div>
      <div class='o-grid__col o-grid__col--4-4-s o-grid__col--2-4-m o-grid__col--2-4-l'>
        {{#if cancel_at_period_end}}
            <span class='u-type-uppercase u-block u-type-600 u-type-sm'>{{t 'Expires' }}</span>
          {{else}}
          <span class='u-type-uppercase u-block u-type-600 u-type-sm'>{{t 'Next bill date' }}</span>
          {{/if}}
        </label>
        <span class='u-type-sm'>{{date current_period_end format="DD.MMM.YYYY"}}</span>
      </div>
    </div>

    <hr class='seperator'>

    <div class='o-grid'>
      <div class='o-grid__col o-grid__col--4-4-s o-grid__col--2-4-m o-grid__col--2-4-l u-mb-16'>
        <a class='c-btn c-btn--full c-btn--small c-btn--light' href='javascript:'
              data-members-edit-billing
              data-members-success='/account/?stripe=billing-update-success'
              data-members-cancel='/account/?stripe=billing-update-cancel'>{{t 'Edit billing info'}}</a>
      </div>
      <div class='o-grid__col o-grid__col--4-4-s o-grid__col--2-4-m o-grid__col--2-4-l'>
        {{#if cancel_at_period_end}}
          {{cancel_link
            class='c-btn c-btn--full c-btn--small c-btn--action'
            errorClass='u-alert u-alert--error u-mt-16 u-block'
          }}
        {{else}}
          {{cancel_link
            class='c-btn c-btn--full c-btn--small c-btn--dark'
            errorClass='u-alert u-alert--error u-mt-16 u-block'
          }}
        {{/if}}
      </div>
    </div>
  {{/foreach}}
</div>
</div>
{{else if @member}}
<div class='c-archive'>
  <div class='o-grid'>
    <div class='o-grid__col o-grid__col--center o-grid__col--4-4-s o-grid__col--3-4-m o-grid__col--2-4-l'>

      <h1 class='c-archive__title'>Free members updates</h1>
      <p class='c-archive__description'>{{t "You are subscribed to free updates from {siteTitle}, but don't have a paid subscription to read all the posts." siteTitle=@site.title}}</p>
      <hr>
      <p class='u-text-center'><a class='c-btn c-btn--action' href='/signup/'>{{t 'Subscribe Now'}}</a></p>
    </div>
  </div>
</div>

{{else}}
{{!-- Not logged in: Redirect to signin --}}
<script>window.location = '{{@site.url}}/signin/';</script>
{{/if}}
</div>

The part after {{else if @member}} gets displayed correctly to non-paid members.
Yet, the “main part” → {{#if @member.paid}} yields a 404 when a paid, active member goes to /account/. This code sits in the members/account.hbs file.

I think the issue is at this part:

{{ price currency=currency }}{{ price plan.amount }} {{ plan.currency }} / {{ plan.interval }}

You should replace the above mentioned code with:

{{price plan}}/{{plan.interval}}

Of course depending on what formatting you want to have you can look into the price helper.

Thank you @bironthemes :slight_smile:
That was the actual issue with the code. Has it changed in the 3.x → 4.0 update of Ghost?

Yes, you can check your theme with the gscan tool to see if there is any other issue.

You can also find a full list of all the breaking changes here:

But making gscan part of your development workflow is the quickest and easiest way to keep on top of theme changes, it can be used to as a CLI-based testing tool to validate your theme as well as the online version.

Yea, I’m asking cause I put my theme through a Gscan, picked up a few errors and issues and fixed them so I had 100/100 score. This “mistake” was there and gscan didn’t highlight it as an error/issue/etc.