Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gravity Wiz // Skip Registration for Logged In Users
<?php
/**
* Skip Registration for Logged In Users
* http://gravitywiz.com/2012/04/24/skip-user-registration-for-logged-in-users/
* Works for GF User Registration versions before 3.0. For version 3.0 and greater, use this alternate snippet:
* https://gist.github.com/spivurno/a9d80f6afb5cd46cf8c2
*/
add_action('gform_post_submission', 'maybe_skip_registration', 9);
add_action('gform_after_submission', 'maybe_skip_registration', 9);
function maybe_skip_registration($entry) {
if(is_user_logged_in()) {
remove_action('gform_post_submission', array('GFUser', 'gf_create_user'));
remove_action('gform_after_submission', array('GFUser', 'gf_create_user'));
}
}
add_filter('gform_validation', 'maybe_skip_validation', 9);
function maybe_skip_validation($validation_result) {
if(is_user_logged_in()) {
remove_filter('gform_validation', array('GFUser', 'user_registration_validation'));
}
return $validation_result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.