Change custom registration form's default_errors message and/or error redirect page

Tourist
19 0 3

Hello,

Wondering if there is a way to change a custom customer registration form's default_errors message.

I have tried @jason's code found on another topic:

{% form 'create_customer', class: 'form_validation' %}

Jason's code here:
{% if form.errors %}
 {% for field in form.errors %}
   {% if form.errors.messages[field] contains "has already been taken" %}
      Show something else...
   {% endif %}
  {% endfor %}
{% endif %}

<input type="hidden" id="customer_tags" name="customer[tags]" value="wholesale"/>
...

But unfortunately, when the user's email address already exists, it takes you to /account/register page with the default message "This email address is already associated with an account. If this account is yours, you can reset your password."

GOAL:

Since this is a custom registration form, is there a method to avoid redirecting the customer to /account/register and instead keep them on the custom reg page with a custom message?

ALTERNATIVE:

If a message is not possible, can there be a way to redirect the user to a different page instead of /account/register? This way, that page could give specific instructions to try again.

Any suggestions much appreciated thx

0 Likes
Shopify Partner
221 0 13

Hey there,

I see two options that could be used toghether.

1. To change the messages of that return the register and login form are in the language options from the Theme page. You go Online Store>Themes>... (Go to the menu of the published Theme)>Edit Lengague  Now to find the words you want to change simply copy the messages given by the form and crtl+F to find them on the Edit Languages site. And there you go, just change what you want it to say there.

NOTE: If you want to add a a few more validations, all you have to do is use jquery or javascript to hear when the form is submited like so:

//This for login and #create_customer for the register form.
$('#customer_login').on('submit', function(e) {
//Write here your validations
//And use this to prevent the form from submiting in case validations are not met.
e.preventDefault();
});

2.  Now for the magic of making everything happen in the same page and control where you want the login and register forms to go, you can see the next tutorial and build it to fit your needs :D 

http://inside.sauce.ly/how-to-build-an-ajax-login-form-on-shopify/

It explains really well how to catch all validations from a register and logins forms and helps your generate Ajax responses. Really nifty stuff :D 

I think the tutorial will help you really well. Its well explained and fits what you want to do. I used it and build a nice Ajax login on page of ours :D Hope this helps, if you have a question do respond, Ill try to help :D 

Good Luck & Keep on Coding! :D

 

Entrepreneur, Developer, Geek, Gamer and very passionate about WEB development! :P

Need help with your Shopify Store? Contact me: jfeuchter@gmail.com :D
0 Likes
Tourist
19 0 3

Thanks Jurgen!

Great suggestions - I didn't even think about your first suggestion which is a great idea for a temporary message to accommodate multiple types of users. 

Re: validation, I'm currently using the standard jquery validate script but unfortunately I can't pre-validate if an email already exists in Shopify but... your 2nd suggestion sounds very promising.

I'll study up this one and appreciate you sharing this. Thanks!

Cheers!

0 Likes
Shopify Partner
221 0 13

If you need any help with the implementation, Ill be around hehe. Im suscribed to the thread so Ill know when you post a question.

Good Luck! :D 

Entrepreneur, Developer, Geek, Gamer and very passionate about WEB development! :P

Need help with your Shopify Store? Contact me: jfeuchter@gmail.com :D
0 Likes
New Member
5 0 0

Hey the link above is not working anymore, any ideas?

0 Likes
Highlighted
Shopify Partner
221 0 13

Hmm the site seems to be down, not sure why. Well the code is on GifHub as well, you can acces it here:

https://gist.github.com/chrisjhoughton/3c9c5b452b1f7e5cc7eb

Though the steps on how to do it is not there. If you know your way around JS code, there should be no trouble. :P Good luck! :D 

Cheers!

Entrepreneur, Developer, Geek, Gamer and very passionate about WEB development! :P

Need help with your Shopify Store? Contact me: jfeuchter@gmail.com :D
0 Likes