Hello everyone,
I’m trying to implement a sign in section in my ghost theme.
I have this in my home.hbs file (custom page):
<div class="get-in-touch">
<h2 class="title">Get in touch</h2>
<div class="sign-in-box">
<form data-members-form="subscribe" method="post">
<div class="mail-label">
<label for="mail">
Sign in to recieve our latest post
</label>
</div>
<input data-members-email type="email" required="true" name="mail" placeholder="Your email">
<div class="submit-btn">
<button type="submit">Sign up</button>
</div>
</form>
</div>
</div>
When I put my mail and I press the submit button. A post request is performed with the url : http://localhost:2368/?mail=MY_MAIL.
This post takes me to my homepage and that’s all. I don’t see the email address entered in my ghost members, and I don’t receive an invitation email either. (SMTP is configured and I can send email to invite author with the ghost admin)
EDIT:
If I don’t provide a method to the form, a get request will be made to the “/” URL. If I provide the post method then a POST is done on “/” as well.
It seems that my form is not intercepted by the ghost SDK to provide the correct method and action
Are you sure your site is loading the portal code? If you inspect those elements on the page (using your browser’s Dev Tools), can you see that portal has modified them after you submit (it should add a success class to the form element)? If not, that’s the problem to solve.
The minimal form to trigger the subscription would be this one, from the documentation:
It might be worth backing up to the very simple form above to see if that posts. Then add back until it breaks…
UPDATE: I ran your exact code above on my Ghost site, and it does send a magic link successfully. So if it isn’t working on your site, take a good hard look at whether Portal is loading or whether there are errors in the console. The code itself is fine.
I imagine it’s because of the portal code. My form is not updating and the success and error classes do not apply. How can I load correctly the portal code ?
I don’t think I did anything about it at all. I created the ghost project, I made it run and I created my theme. After that I uploaded the zip of my theme that’s all. And now I would like to include a subscription form. Do I have scripts to upload?
Thanks Cathy, that was the solution, I forgot the ghost_head. I don’t know what I would do without you. You are always the one who had the solution :) Thanks for that