Created
May 25, 2019 03:11
-
-
Save claygriffiths/f5e6d63fdd0346a63df223e782e350e6 to your computer and use it in GitHub Desktop.
GP Auto Login: Auto-login based off of field/input having a value or being checked.
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 | |
/** | |
* See https://gravitywiz.com/documentation/how-do-i-install-a-snippet/ for details on how to install snippets like these. | |
* | |
* Note: This snippet requires GP Auto Login 1.3.5 or newer. | |
* | |
* The following snippet allows you to conditionally auto-login based on whether or not a field has a value | |
* or is checked. | |
* | |
* $form_id should be replaced with the form ID you wish to apply the login to. | |
* | |
* $input_id should be replaced with the field or input ID that you wish to check. The login below checks if the | |
* field/input is checked or has a value. | |
*/ | |
add_filter( 'gpal_auto_login', function ( $auto_login, $user_id, $feed, $entry ) { | |
$form_id = 47; | |
$input_id = '4.1'; | |
if ( rgar( $entry, 'form_id' ) != $form_id ) { | |
return $auto_login; | |
} | |
if ( ! rgar( $entry, $input_id ) ) { | |
return false; | |
} | |
return $auto_login; | |
}, 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment