Skip to content

Instantly share code, notes, and snippets.

@gicolek
Last active September 2, 2017 16:26
Show Gist options
  • Select an option

  • Save gicolek/93f2dc70afb1b2466fc5 to your computer and use it in GitHub Desktop.

Select an option

Save gicolek/93f2dc70afb1b2466fc5 to your computer and use it in GitHub Desktop.
<?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