Created
March 27, 2024 18:28
-
-
Save scyt/aec3d2effbd35c3b76f102d5a752e556 to your computer and use it in GitHub Desktop.
Gravity Wiz // Gravity Forms // 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 | |
/** | |
* Gravity Wiz // Gravity Forms // Skip Registration for Logged In Users | |
* https://gravitywiz.com/skip-user-registration-for-logged-in-users/ | |
* | |
* Skip registration if the user is logged in. Works for GF User Registration 3.0 and greater. | |
* | |
* Plugin Name: Gravity Forms - Skip Registration for Logged In Users | |
* Plugin URI: https://gravitywiz.com/skip-user-registration-for-logged-in-users/ | |
* Description: Skip registration if the user is logged in. | |
* Author: Gravity Wiz | |
* Version: 0.1 | |
* Author URI: https://gravitywiz.com/ | |
*/ | |
// Update "123" to your Form ID. | |
add_filter( 'gform_is_delayed_pre_process_feed_123', 'maybe_delay_feeds', 10, 4 ); | |
function maybe_delay_feeds( $is_delayed, $form, $entry, $slug ) { | |
if ( is_user_logged_in() && $slug == 'gravityformsuserregistration' ) { | |
return gf_user_registration()->has_feed_type( 'create', $form ); | |
} | |
return $is_delayed; | |
} | |
// Update "123" to your Form ID. | |
add_action( 'gform_pre_process_123', 'maybe_skip_validation' ); | |
function maybe_skip_validation( $form ) { | |
if ( is_user_logged_in() && function_exists( 'gf_user_registration' ) && gf_user_registration()->has_feed_type( 'create', $form ) ) { | |
remove_filter( 'gform_validation', array( gf_user_registration(), 'validate' ) ); | |
} | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment