Last active
September 2, 2017 16:26
-
-
Save gicolek/93f2dc70afb1b2466fc5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| // the _3 prefix has to match the id of the form you have created | |
| add_action( "gform_after_submission_3", "login_form_after_submission", 10, 2 ); | |
| function login_form_after_submission($entry, $form) { | |
| // get the username and pass | |
| $username = $entry[1]; | |
| $pass = $entry[2]; | |
| $creds = array(); | |
| // create the credentials array | |
| $creds['user_login'] = $username; | |
| $creds['user_password'] = $pass; | |
| // sign in the user and set him as the logged in user | |
| $sign = wp_signon( $creds ); | |
| wp_set_current_user( $sign->ID ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment