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.

Newbie here...

  1. cmendoza
    Member

    Hello

    I just purchased Gravity Forms and had a quick question I'm hoping you can help with or at least point me towards some examples.

    The form is intended to allow users and visitors alike submit "posts".

    What I'd like to do is prompt the individual for their name and email address if they are not a current user and give them the oppourtunity to "register" should they choose to do so or log in if they are a current user and simply forgot to log in.

    Your help would be greatly appreciated.

    Best Regards,
    Carlos

    BTW, I did try searching the forums, but if this has already been addressed, please feel free to simply point me towards said post or suggest how I might find it...

    Posted 13 years ago on Tuesday August 31, 2010 | Permalink
  2. Their might be a better way, but this can be accomplished by taking advantage of Gravity Forms gform_pre_render filter. Using this filter you could call a function that checks if the user is logged in or not - if not, you can output some CSS to hide the form and then output a registration/sign-up form in it's place.

    Here is the barebones usage of the gform_pre_render filter: http://pastie.org/1131317

    EDIT//

    With that said, I just noticed the title of your post which might mean this is not going to be an ideal solution for you, but... worth a shot. ;)

    Posted 13 years ago on Wednesday September 1, 2010 | Permalink
  3. cmendoza
    Member

    Thanks David, I understand what you're saying, but it doesn't quite fit what I'm trying to do. That is, I'm not trying to hide the form, but rather show / not show specific fields... while waiting for a reply I've been messing with the form builder and think I can do it with the "conditional logic" functionality.

    However, it seems that only certain fields can be used for the check... are those fields documented somewhere?

    That is, I tried putting in a "hidden" field and setting it to {user:user_login} which would contain a value if the user is logged in and would be empty if not... but the field doesn't show up in the drop-down when I try to set the conditional logic on the "email" field.

    Any thoughts?

    Thanks again,
    Carlos

    Posted 13 years ago on Wednesday September 1, 2010 | Permalink
  4. You can only create conditional logic based on drop downs, check boxes and multiple choice fields. Fortunately, this doesn't pose too much of an issue and requires only minimal customization to get working.

    1. First you'll want to set up a multiple choice field labeled "Registered" and with two options: "Yes" and "No". Should look something like this: http://grab.by/6bD3
    2. Go ahead and setup two additional fields that have conditional logic based on the "Registered" multiple choice field. One that displays if "Yes" is selected and one that displays if "No" is selected.
    3. Next, you'll want to add the following code to your functions.php: http://pastie.org/1132037

      This snippet of code checks if the user is logged in before the form is rendered on the page. If the user is logged in, it specifies the "Yes" option of the "Registered" multiple choice field.

      Important: You will need to update a few values to ensure that this snippet works with your form:

      • if($form['id'] != 3) return $form;
        Update the 3 to the form ID of your form
      • $form['fields'][0]['choices'][0]['isSelected'] = 1;
        Update the first 0 to the field ID of the "Registered" multiple choice field you created in your form. Do the same for the line two lines beneath this one.
    4. To see a working example of this check out this rough demo: http://gravityforms.ounceoftalent.com/2010/09/check-for-registered-user/ I've left the multiple choice field revealed so you can see what is going on, but in the final product, you can easily hide this field with CSS.

    Posted 13 years ago on Wednesday September 1, 2010 | Permalink