Redirect if email already exists

Hello,

Can I know how can I set up a condition to be redirected to another page if a user already exists? This option of getting the username is not available in the default Gravity forms conditions.

What I tried was to

Store entry to a variable. check for $username with username_exists() function and then redirect using array of confirmation.

add_action('gform_confirmation_2', 'redirect_registered_to_gated', 100, 4 );

function redirect_registered_to_gated( $confirmation, $form, $entry, $ajax)
{

$username = strtolower( rgar($entry, '7'));

if ( $form['id'] == '2' && username_exists( $username )) {

	$confirmation = array( 'redirect' => 'https://url' );
}

return $confirmation;
 }

Do I need to do anything more?

Have you already tried this? It seems like it would work but I did not test it.

Yes, I tried it but the problem is that it redirects even if the username does not exist. This is because the user registration is active and user is added even before confirmation. Do I need to target a different tag?

Hi Alexander. What is it you are trying to do? What is the end goal? Maybe we can come up with a better solution. Thank you

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.