0

Checking the best way to achieve this or if it can be done without a plugin. I need to allow people to register and create user accounts on my site with various profile information.

Then I will have a form on the site available to users to submit which saves it in the backend and alerts by email. (A&M forms looks like it has this functionality). When a user logs in this form should be prepopulated with data from their user profile.

When the form is submitted - can it update their user profile also?

It is basically a form for users to order repeat prescriptions - so I'm thinking user profile to save the standard date then use that to prepopulate the a&m form. Is what I'm suggesting the best way to achieve this?

3

Yep, that's totally do-able. Check out this article to see how to create a registration form.

Then check out this article to see how to create the update profile form.

The thing to note is that any custom fields like address or city need to be pre-pended with fields.

So, let's say you want the user to enter their city. On your front-end form the markup looks like this:

<h3><label for="city">City</label></h3>
<input id="city" type="text" name="fields[city]"
{%- if currentUser is defined %} value="{{ currentUser.city }}"{% endif %}>
    {% if currentUser is defined %}
        {{ errorList(currentUser.getErrors('city')) }}
    {% endif %}

... and so on.

Make sure that your field handle(s) in the CP align with what you call them on your front-end form.

Here is how you can check for the current user.

Here is another great example of how to populate custom fields in your profile/registration form.

Hope this helps!

| improve this answer | |
  • Thanks - I have created users account forms etc all before - all fairly straight forward; Then when a user is logged in to Order a repeat prescription - that User Profile Data would auto-complete the Order Form - I was thinking of using the a&m forms plugin for that - so each Order is stored in the CMS and an email sent. I was wondering when that order form is submitted could that also update their user profile if there was any differences in it? – mmc501 Dec 4 '15 at 15:16
  • I'm sure there is a way. My guess is that you would need to create some sort of plugin that listens to the order form submit, then updates the user profile within craft. – Damon Dec 4 '15 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.