PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

User registration problem

  1. Hello,
    I've a contact form for user registration using the 'user registration' addon. The problem, is when the user fill and submit the contact form this user is automatically registered in WP. So, if the same user, needs to fill the form another time to contact, the plugin shows a message like this: "This email address is already registered". I need to allow the users to contact more than once and whit this limitations this is not possible.

    How can solve that problem?

    Regards,

    Posted 12 years ago on Wednesday October 26, 2011 | Permalink
  2. Hi Ruben,

    Here is a solution:

    1. Add a checkbox field to your form titled, "Register User". It should have a single option labeled, "Yes".
    2. Set the visibility of this field to admin only. This will prevent users filling out the form from seeing this field.
    3. You'll have to create some custom code using the gform_pre_submission hook that checks the value of the submitted email (available in the $_POST global) and then using the WordPress email_exists() function, check if the email has already been registered.
    4. If it has not been registered, you'd manually add a value to the $_POST for the "Register User" field so as Gravity Forms continues processing the form submission it will capture this dynamically populated value.
    5. The last piece is to update your User Registration feed with a condition: If "Register User" is "Yes".

    I know that is a lot to take in, but hopefully it's good for a start. Feel free to ask questions. :)

    Posted 12 years ago on Wednesday October 26, 2011 | Permalink
  3. Hi David,

    I'm trying to code your suggestion, but I think I'm doing somethig bad, because it seems that the form checks if the email is registered before my hook is executed. My code is something like this:

    [php]
    add_action()add_action("gform_pre_submission_1", "pre_submission");
    function pre_submission()
    {
      $email = $_POST['input_3']; // input 3 is the email field
      if (! email_exists($email))
         $_POST['input_17'] = "Yes";  // input_17 is the hidden checkbox
    }

    What's wrong?

    Thanks

    Posted 12 years ago on Thursday October 27, 2011 | Permalink
  4. @rubencio, please try using the $form object as a parameter in your pre_submission function, like this:

    [php]
    add_action("gform_pre_submission_1", "pre_submission");
    function pre_submission($form){
        // input 3 is the email field
        $email = $_POST['input_3'];
        if (!email_exists($email))
            // input_17 is the hidden checkbox
            $_POST['input_17'] = "Yes";
    }

    The documentation for the hook is here:
    http://www.gravityhelp.com/documentation/page/Gform_pre_submission

    Posted 12 years ago on Friday October 28, 2011 | Permalink
  5. Hi David & Chris Hajer,

    My hook is exactly like you propose but doesn't works. Please, can you test the form directly at this URL?

    http://apptheming.com/get-a-quote/

    You can fill the form and submit, so, the first time you will be registered. Then, if you want to get another quote, you can't...

    Thanks

    Posted 12 years ago on Friday October 28, 2011 | Permalink
  6. I tried to submit the first time around, and got a 404 error with this URL in the address bar:

    http://apptheming.com/get-a-quote/:/

    Posted 12 years ago on Friday October 28, 2011 | Permalink
  7. Please,

    Try this:

    http://apptheming.com/get-a-quote

    Regards

    Posted 12 years ago on Saturday October 29, 2011 | Permalink
  8. Tried it. Submitted once. Tried to submit myself again with the same real name and email address, and I received validation errors as expected. Screenshot: http://min.us/mbdqkS4O7t

    Is that what's supposed to happen?

    Posted 12 years ago on Saturday October 29, 2011 | Permalink
  9. Absolutely no!
    It suppose once you are registered (with your previous form filled) you can submit infinite forms again and again... actually that's the reason why I'm asking here.
    Best regards

    Posted 12 years ago on Saturday October 29, 2011 | Permalink
  10. The idea it is you can submit your first form asking for a quote and this process automatically will add you to the DB as a user... but later you can use the same form as many times as you need.
    The way it is now (after the mod from David Smith) you can submit only once. Does this make sense?
    Best regards.

    Posted 12 years ago on Saturday October 29, 2011 | Permalink
  11. So the functionality I am seeing here is the default. What you're trying to do is skip the registration for a logged in user?

    How about splitting it into two forms: registration first and quote request second. Only show the second form if the user is logged in (that functionality is available in 1.6: if the user is not logged in, don't show them the 2nd form. Show them alternate content, or even another form, like the registration form.)

    Would that work?

    Posted 12 years ago on Sunday October 30, 2011 | Permalink
  12. What I am trying to do it is NOT skip the registration for "logged in users" (I have not talked about logged in)... I simply need the form to be available, even for already registered users, more than once.

    Let me explain my model further: we have this form for potential clients to ask us for a quote. Once those clients submit the form they automatically become "registered users" as subscribers in our database (it has nothing to do about logged in). So the problem come when they try to use the form next time they need to request another quote since they are already registered and received the message "This email address is already registered"... make sense now?

    @Chris: Hope this is clear for you now. It seems David Smith got it at the very first moment.

    Posted 12 years ago on Monday October 31, 2011 | Permalink
  13. Currently you can't use the same form to both register a user AND for registered users to fill out.

    BUT there is a way around this... but it still requires 2 forms. AND it is going to require using Gravity Forms v1.6 which will be released via automatic update either later today or most likely sometime tomorrow.

    1) Create the form you want logged in registered users to fill out

    2) Create the form you want non-registered users to fill out

    On the form you want the registered users to see do the following...

    - Edit the form
    - Edit Form Settings
    - Select Advanced Tab
    - Check the "Require user to be logged in" checkbox
    - In the Require Login Message you can then insert a Gravity Forms shortcode to show the form that you want to show if the user is NOT logged in

    Now embed this form on the page you want to link to.

    When a logged in users goes to it, they'll see the form.

    When a user that is not logged in goes to it, they'll see whatever form you specified using the shortcode in the require login message.

    So while it still uses 2 different forms, it can appear more seamless for the user.

    Posted 12 years ago on Monday October 31, 2011 | Permalink
  14. Hi Carl, Actually my registered users will be never logged in to the site. That's what make me think a second form will be simply useless.
    I only need one form to be filled and when the "User Registration" detect the email already exist, simply do not try to create the user and show "This email address is already registered"... but let the user to send his request (form) anyway.
    Make sense? Is this possible?

    Posted 12 years ago on Friday November 4, 2011 | Permalink
  15. I have the exact same issue for a different usage.
    A simple extra option in User Registration Add-On would surely do it:
    Register if <email_field> is "unknown in DB".

    Posted 12 years ago on Friday November 4, 2011 | Permalink
  16. Yep. Same problem here. I need registered (logged in or not) users to be able to fill out the registration form and submit it.

    Unregistered users gets registered and added to the forms entries list.
    Registered users only gets added to the forms entries list.

    Posted 12 years ago on Friday November 4, 2011 | Permalink
  17. andrew carbn
    Member

    I wanna get on this waggon too!

    My form problem happens if people were to add their details on the final step of Billing detiails etc. and then get directed to PayPal (works fine) but if there were to hit 'back' on the browser (They may have wanted to click back and see that they spelled something correctly etc.), the form then has in red:

    There was a problem with your submission. Errors have been highlighted below.

    Your Name*
    FirstLast
    This username is already registered
    Email*
    Used only to receive information regarding this order.
    Enter EmailConfirm Email
    This email address is already registered

    So they can't actually click next and pay at paypal.

    Posted 12 years ago on Wednesday November 9, 2011 | Permalink
  18. A registration form is a registration form. If a user is already registered then they shouldn't be filling out the registration form AND if they do they will get a message saying their email is already in use. That is how the User Registration functionality works.

    If you want a form that both registered and non-registered users fill out then you need to make a form that doesn't create users and use that form for what you are doing.

    @andrew carbn Your issue is completely unrelated to the issue being discussed in this thread. Your problem isn't related to registered and non-registered users filling out a form. Your problem is related to the fact that once a user submits the form and gets redirected to PayPal... the form has already been submitted at that point. They can't click the back button and make changes and then go forward.

    Once they are redirected to PayPal they must complete the process. Once the form is submitted, it's submitted. There is no going back and changing the information. The form has already been processed at that point.

    If you are using PayPal to create a user then you would need to set the PayPal settings so that the user is only created AFTER payment is received. If you have an email field and you have configured it so that it requires a unique value, that is a different issue and the user won't be able to click back and then submit the form again.

    Posted 12 years ago on Wednesday November 9, 2011 | Permalink
  19. Just like Rubencio, I try to do a 'quote form'. I have the same requirements, as clients won't be necessarly connected to make a new quote. This improves a lot the conversion rate. Mixing the user registration into the quote form is a very good approach to me. I also thought Gravity User Reg Add-on could help me save coding time by handling the User Reg process easily. Registration conditions shows the add-on has some flexibility. It would be great if this could be improved the way rubencio & I describe it. Duplicating forms is not a solution for me, because I have a dozen of different forms to create. This would be unadministrable ! I hope this make sense !

    Posted 12 years ago on Wednesday November 9, 2011 | Permalink
  20. So I'm just wanting to clarify; will the solution above work for the following.

    • Scenario 1 User fills out a form which they can purchase something through. This form registers the user.
    • Scenario 2 The user doesn't log in but wants to purchase another item. Their email address already exists as a registered user.

    How do i get this to work? Any ideas? If this should have been in another thread please let me know and I'll make a new one.

    Posted 12 years ago on Wednesday November 16, 2011 | Permalink
  21. @suiwrl One solution would be to add a field to your form that asks the user is he is an existing user or not. If they are not an existing user, then show the registration related fields using conditional logic. If they are an existing user then you can use conditional logic to hide the registration related fields.

    Then in the User Registration Add-On feed for that form you can configure the Registration Condition. The Registration Condition lets you configure the form so that the registration process only happens if the user makes a certain selection on the form. Ex. they select they are a new user from the field that asks if they are a new or existing user.

    If they are an existing user and they choose new user... they will see right away that their email is already in use so they must be an existing user. So they can simply change the form field that asks if they are new or existing to existing.

    That is the simplest way to handle what you have described.

    The other solution is to create 2 different forms. One for new users that also registers them and a second for existing users that does not have registration functionality.

    Posted 12 years ago on Wednesday November 16, 2011 | Permalink
  22. Hi Carl,

    I see your point of using the user registration functionality for user registrations, but it seems that the additional functionality is required by more than 1 person, including me. I would love to see the functionality to only register if the user if they don't exist and to simply ignore the registration process if the user exists. I feel like it should be an option.

    My requirements is purely a back end thing. The user never logs into the site so I want the registration to be transparent to the user. (At a later stag I will be integrating user logins to the site, but not yet)

    Nathan

    Posted 11 years ago on Saturday May 19, 2012 | Permalink
  23. Is there a way to do this with hooks?

    Posted 11 years ago on Saturday May 19, 2012 | Permalink
  24. I'm looking for a solution to the scenario discussed in this thread (Register if <email_field> is "unknown in DB"). Anyone willing to share what they eventually implemented?

    Best.

    Posted 11 years ago on Sunday August 26, 2012 | Permalink
  25. @joeurudi, can you please post the flow on your site and how you want the registration process to work? Thank you.

    Posted 11 years ago on Monday August 27, 2012 | Permalink
  26. @Chris, the best scenario for me would that the Registration Add-On allowed for a condition that said "Register the user if <the_form_email_field> is not owned by an existing user". I'm looking for the exact same solution as @rubencio, @mediana, @Bjarne, and @Nathan.

    I'm actually 98% finished with an ugly, albeit functional, albeit ugly (did I say ugly?), workaround that solves my problem and doesn't require a user to login or use two forms like described by @Carl. But I was hoping someone had a better solution.

    Regards

    Posted 11 years ago on Monday August 27, 2012 | Permalink
  27. OK - after spending all day on this, I came up with a solution that works for my situation. I'll describe it here for others, but by no means do I expect this will work in all scenarios. However, if you do find this useful *and* you find a way to improve upon it, please share.

    Basically, I found that I had to setup two different email fields (one hidden) on two different form pages. Then I had to use hidden radio buttons to say whether we're dealing with a new user or existing user. Then I had to modify my Registration Add-On settings. Finally, add some hooks and javascript to tie it all together.

    1. On a multiple page form, prior to including any other Email field, include a single line text field. Let's say page #2, and call the field "Enter Email" and make it required. Let's assume that field ends up with a form input name of "input_10". This is where the user will enter their email address. I'm pretty sure you can put some formatting validation on that field through GV, but I haven't done it yet. If not, there's always some javascript you could use.

    2. Save your form.

    3. Just below "Enter Email", make a radio button field. Let's assume that field ends up with a form input name of "input_11". Let's give that field a label of "is_registered". For the radio buttons, give one a value of "Yes" and one a value of "No". Make the "Yes" the default. Make the button required. On the Advanced tab, change Visibility to Admin Only and check Allow field to be populated dynamically (not really sure if that's necessary or not). Leave the parameter blank.

    4. Save your form.

    5. At this point, you should *not* have included the standard Email form field anywhere before step #1. But now it's time to add it. However, you need to add it on the next form page. So go ahead and add a page break, if you don't already have one.

    6. Save your form

    7. On the new page, add the standard Email field and label it "Your Email". Let's assume that this field has a form input name of "input_15". Make it required. On the Advanced tab, you have to leave this field visible to everyone, cuz this process doesn't work with it hidden. However, we don't want people to see this field because they already entered their email address in the step #1 field. So we have to throw some CSS on it to hide it. In the CSS Class Name field, enter "iamhidden". We'll create the CSS in a bit.

    8. I left the "Allow field to be populated dynamically" field unchecked because I couldn't figure out a good way to use it, but I tried. This is an area that someone might really be able to improve upon. Because instead, we have to use some javascript to populate this "Your Email" field - we'll to that in a bit.

    9. I was finding that I needed another form field on this page. That may or may not be true. Either way, you don't want users looking at a blank form, so you'll have to add something. Your form scenario probably lends itself to that anyway.

    10. Save your form

    11. Jump over into your User Registration Settings/Feed (I'm assuming you already have this setup to some degree). Set the username field to the "Your Email" that you created; set the Email Address field to the "Your Email" that you created; set password to "Auto Generate Password"; set all other fields as appropriate.

    12. Check the box for the Registration Condition. Set the drop-downs to "is_registered" "is" "No".

    13. If you're automatically creating posts, you'll probably want to enable "Set As Post Author". But keep in mind that the post author will only be set to the user when it's a newly registered user (due to the fact that we just placed the conditional in step #12). So if you check the box, you'll need to add another hook later on to set existing users as post authors. The drawback to that is you'll be setting post author without necessarily authenticating the user, which could have some negative consequences. I'll show you the code to set the author, but it's kinda a separate topic.

    14. Save the settings

    15. Open your functions.php file and add the following code. This code will get executed when the user navigates from form-page-to-form-page. This code will get the email address from the field we created in step #1 (Enter Email) and look at Wordpress to see if there is an existing user with that email address. If the user doesn't exist, the radio buttons (from step #3) are set to No. This in turn tells the Registration Add-On to create a new user. If the user does exist, the radio button are set to Yes and the registration process won't get in the way of adding a new entry because of the conditional we set in step #12:
    http://pastie.org/4596054

    16. As described in step #13, you may or may not want to add the following code to your functions.php file. This is the code that will update a post's author when your user isn't logged in. Again, there are some real security downsides to this (like other people possibly being able to see someone else's post). So if you're gonna do this, you really should know what you're doing. Otherwise, don't.
    http://pastie.org/4596080

    17. Save functions.php

    18. Open the file you're using to style your forms. As mentioned in step #7, we need to hide the "Your Email" field. Add the following to you stylesheet:
    http://pastie.org/4596116

    19. Finally, we have to add the code that will copy the email address from "Enter Email" to "Your Email". We do this via javascript. So open main.js or whatever file you're keeping your scripts and add the following. Be sure to replace the numbers with the appropriate numbers of your actual form and fields:
    http://pastie.org/4596135

    20. Make sure everything is saved and then test.

    Hopefully I haven't forgotten anything. I really don't have time to support issues on all of this, so it's best to understand what you're doing here.

    And maybe soon, the fine people at rocketgenius will just implement the (Register if <email_field> is "unknown in DB") condition in the Add-on.

    :)

    Posted 11 years ago on Monday August 27, 2012 | Permalink
  28. Thank you for posting that comprehensive write up. If you have a blog and would like to post it there, please feel free and we'll add the link here.

    Posted 11 years ago on Monday August 27, 2012 | Permalink