gform_user_registration_login_redirect_url

Description

Filters the redirect URL after login when using the User Registration add-on login widget.

Usage

add_filter( 'gform_user_registration_login_redirect_url', 'your_function_name', 10, 2 );

Parameters

  • $login_redirect string

    The URL to which the user will be redirected.

  • $sign_on object

    The WP_User on success.

Examples

Redirect all users to a custom URL

add_filter( 'gform_user_registration_login_redirect_url', 'your_function_name', 10, 2 );
function your_function_name( $login_redirect, $sign_on ) {
	return 'https://localhost/wp.dev/my-account/';
}

Redirect to a custom URL only for users with ‘administrator’ role

add_filter( 'gform_user_registration_login_redirect_url', 'gf_redirect_user_role', 10, 2 );
function gf_redirect_user_role( $login_redirect, $sign_on ) {
	GFCommon::log_debug( __METHOD__ . '(): Running...' );
	if ( in_array( 'administrator', $sign_on->roles ) ) {
		// Redirect users with administrator role to a specific page.
		$login_redirect = 'https://example.com/';
		GFCommon::log_debug( __METHOD__ . '(): Redirecting to ' . $login_redirect );
	}

	return $login_redirect;
}

Placement

This code should be placed in the functions.php file of your active theme.

Since

This filter was added in the User Registration version 3.2.

Source Code

This action hook is located in GF_User_Registration::handle_login_submission() in gravityformsuserregistration/class-gf-user-registration.php.