Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zackeryfretty/f0e0220349d95b1956f697e816536327 to your computer and use it in GitHub Desktop.
Save zackeryfretty/f0e0220349d95b1956f697e816536327 to your computer and use it in GitHub Desktop.
// Integrate WPF Return into Gravity Forms Login Shortcode
function zf_check_for_wpf_return_cookie_on_login( $login_redirect, $sign_on ) {
// Check for WPF Return Cookie and ensure it's a valid post ID
if ( isset( $_COOKIE["wpf_return_to"] ) && is_numeric( $_COOKIE["wpf_return_to"] ) ) {
// Get Permalink for the specified post ID
$return_url = get_permalink( (int) $_COOKIE["wpf_return_to"] );
// Set Redirect to the sanitized URL
$login_redirect = esc_url( $return_url );
}
return $login_redirect;
}
add_filter( 'gform_user_registration_login_redirect_url', 'zf_check_for_wpf_return_cookie_on_login', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment