Gravity Forms and Membership SignUp

I’m playing with the R1 membership plugin and I like what you guys have done with it. And what I would really love is to be bale to use gravityforms for the registration form. I know you can use it for account creation in regular wp as well as bp, but I haven’t had any luck with it and membership.

Thanks for all the great plugins!

  • Mason
    • DEV MAN’s Sidekick

    Hiya beturgo,

    Thanks for your kind words here. We’re not done yet either, more to come soon!

    That kind of integration would take quite a bit of work. It IS something we’ve discussed internally, so I won’t say it’ll never happen, but there’s no quick solution unfortunately.

    I’m gonna put this as a feature request. Are other members interest in this one? Thanks!

  • KevinDLyons
    • Flash Drive

    I'm successfully using Gravity Forms (dev version with User Registration add on) with Membership 3.x tying it in to both account generation and a 5-part profile that feeds in to BuddyPress (about 30 fields of data). It works great. I am mainly using it for field validation and standardized data forms like collecting addresses with state and country drop-downs. So the workflow is:

    1. Subscription Page (Page with [subscriptionform] embedded to choose subscription)

    2. Gravity multi-part registration/BP profile creation page which on completion the user is automatically loggin in.

    3. Payment page using the AuthorizeNetAIM gateway and success on payment.

    The only three pieces of magic beyond some field mappings are:

    a. I set the Gravity form to store the url parameter "https://domain.com/member-registration/?action=registeruser&subscription=1" in a hidden field and then upon form completion redirected to the same page and parameter. I have 7 subscriptions so I carried the number on the end as the only dynamic parameter and the rest as a static url.

    b. I added the following code to my theme functions.php file to have the new Gravity forms user automatically log in:

    <?php

    /* Log User in After Registration */

    remove_action(&quot;gform_post_submission&quot;, array(&quot;GFUser&quot;, &quot;gf_create_user&quot;));
    add_action(&quot;gform_after_submission&quot;, array(&quot;GFUser&quot;, &quot;gf_create_user&quot;), 10, 2);

    add_action(&quot;gform_user_registered&quot;, &quot;autologin&quot;, 10, 4);
    function autologin($user_id, $config, $entry, $password) {

    $form = RGFormsModel::get_form_meta($entry['form_id']);

    $user_login = apply_filters(&quot;gform_username_{$form['id']}&quot;,
    apply_filters('gform_username', GFUser::get_meta_value('username', $config, $form, $entry), $config, $form, $entry),
    $config, $form, $entry);

    $redirect_url = rgars($form, 'confirmation/url') ? rgars($form, 'confirmation/url') : get_bloginfo('home');

    //pass the above to the wp_signon function
    $result = wp_signon(array('user_login' => $user_login, 'user_password' => $password, 'remember' => false));

    if(!is_wp_error($result))
    wp_redirect($redirect_url);

    }
    ?>

    c. I hacked ../plugins/membership/membershipincludes/includes/bp.registration.form.php and deleted everything and replaced it with a call to the Gravity form. You can get the Gravity form parmeter settings from their website but the code below calls the form with the id of "6" and prevents Ajax processing. Ajax breaks the session variable for some reason.

    <div id=&quot;memregform&quot; class=&quot;mem-reg-form&quot;>
    <?php gravity_form(6, false, false, false, '', false); ?>
    </div>

    It works GREAT. I hope this helps.

    Kevin

  • Me
    • WPMU DEV Initiate

    Hi Kevin,

    Thanks so much for posting this.

    I’m struggling to replicate though. Have created form, have entered hidden field with URL and parameter, have set up redirect to the same URL and parameter but the form (when hit submit) just hangs (with that circle working animation).

    What I haven’t done however is b) and c) yet… Are they necessary for it all to work?

    Andy

  • Me
    • WPMU DEV Initiate

    Hi again…

    Just thought I’d update. Have also tried b) and c) but I’m getting the following error:

    Parse error: syntax error, unexpected ‘;’, expecting T_PAAMAYIM_NEKUDOTAYIM in /nfs/c09/h02/mnt/131538/domains/mydomain.com/html/wp-content/themes/parallelus-salutation/functions.php on line 230

    (FYI. I’m more a designer than a developer so apologies if I’m making any obvious mistakes)

    Thanks.

  • bigtrousers
    • Flash Drive

    Code was a paste and was all goofy.

    <?php

    /* Log User in After Registration */

    remove_action("gform_post_submission", array("GFUser", "gf_create_user"));
    add_action("gform_after_submission", array("GFUser", "gf_create_user"), 10, 2);

    add_action("gform_user_registered", "autologin", 10, 4);
    function autologin($user_id, $config, $entry, $password) {

    $form = RGFormsModel::get_form_meta($entry['form_id']);

    $user_login = apply_filters("gform_username_{$form['id']}",
    apply_filters('gform_username', GFUser::get_meta_value('username', $config, $form, $entry), $config, $form, $entry),
    $config, $form, $entry);

    $redirect_url = rgars($form, 'confirmation/url') ? rgars($form, 'confirmation/url') : get_bloginfo('home');

    //pass the above to the wp_signon function
    $result = wp_signon(array('user_login' => $user_login, 'user_password' => $password, 'remember' => false));

    if(!is_wp_error($result))
    wp_redirect($redirect_url);

    }

    Still having issues with the redirection however.

    Nearly there

  • Steven
    • Site Builder, Child of Zeus

    Bigtrousers, ths is the autologin and redirection that I use for Gravity Forms. Works great for me. Just set where you want the redirection to go to on the form itself.

    add_action( 'gform_user_registered', 'pi_gravity_registration_autologin', 10, 4 );

    function pi_gravity_registration_autologin( $user_id, $user_config, $entry, $password ) {
    $user = get_userdata( $user_id );
    $user_login = $user->user_login;
    $user_password = $password;

    wp_signon( array(
    'user_login' => $user_login,
    'user_password' => $user_password,
    'remember' => false
    ) );
    }

  • Steven
    • Site Builder, Child of Zeus

    Sorry I won’t be much help. Usually when I find myself in the same situation I’ll deactivate all my plugins, switch back to the twenty eleven theme (to rule out my theme) and try again. Then add everything in bit by bit until I find the issue.

  • Mason
    • DEV MAN’s Sidekick

    Hiya guys,

    Try this:

    1. Create a Gravity From and set it up for User Registration add-on (you must have version 1.4+).

    2. In the Form Settings set the “Confirmation” to redirect to the appropriate membership registration page.

    3. Embed the GF User Registration form in any page that is NOT a page setup in your Membership Options.

    4. As noted above add the following to your theme’s functions.php:

    add_action( 'gform_user_registered', 'pi_gravity_registration_autologin', 10, 4 );
    /**
    * Auto login after registration.
    */
    function pi_gravity_registration_autologin( $user_id, $user_config, $entry, $password ) {
    $user = get_userdata( $user_id );
    $user_login = $user->user_login;
    $user_password = $password;

    wp_signon( array(
    'user_login' => $user_login,
    'user_password' => $user_password,
    'remember' => false
    ) );
    }

    What’s happening here?

    As noted, we’re auto-logging in the user once they register with gravity forms. Then redirecting them to the membership page.

    Since membership will see them as already being logged in they’ll just be asked to select and process their subscription.

    In my tests this method works and should provide what folks are looking for here. Please let us know how it works for you.

    Other notes: Make sure you’re username field is set to something that won’t allow for spaces (this can cause problems) and that you’re using the latest versions of Gravity Forms and the User Registration add-on.

    Thanks!

  • knobby
    • WPMU DEV Initiate

    This sounds like a plausible solution, but what would be the adjustment in this process to have the user need an e-mail confirmation link to allow first access?

    Then redirect to a message that you need to pick the link sent in email?

    From what I saw with the membership, it adds it’s own page in the middle of registration and you would need to direct the default registration to the Gravity form, correct? I assume that is done in Gravity?

    Sorry for not being familiar enough with all the intricacies, but am just beginning to get into WordPress and have no idea where everything calls to and which php files.

    Thanks

  • Pixeldrummer
    • Site Builder, Child of Zeus

    First you giveth [gravity forms], and then you improveth [membership plugin], and then you takes [gravity forms] away??? No way!

    Please add me to the numbers who want gravity forms back.

    The membership plugin with a full integration with gravity forms will be a thing of beauty!

  • Mason
    • DEV MAN’s Sidekick

    Hiya,

    Please add me to the numbers who want gravity forms back.

    There was never integration for gravity forms as the membership registration form. Nothing’s been removed in that regard. As far as I’m aware the above solution will still work if that’s what you want to do.

    Thanks!

  • Pixeldrummer
    • Site Builder, Child of Zeus

    Perhaps gravity forms were not ‘integrated’ but in the previous version short codes were available with which you could use gravity forms for your registration form. I used it and it worked until the membership upgrade. Mind you, membership as it is now is much better.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.