Last active
November 16, 2015 14:16
-
-
Save spivurno/3711002 to your computer and use it in GitHub Desktop.
Gravity Wiz // Skip Registration for Logged In Users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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