Gravity Forms Wordpress:将用户角色重定向到特定页面
Gravity Forms Wordpress: Redirect users role to a specific page
我从 GF 添加了这个功能,但我不知道如何在条件登录中添加另一个用户,有人可以帮忙吗:
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( 'subscriber', $sign_on->roles ) ){
// Redirect users with subcriber role to a specific page.
$login_redirect = 'https://url';
GFCommon::log_debug( __METHOD__ . '(): Redirecting to ' . $login_redirect );
}
return $login_redirect;
}
您可以简单地添加一个'else if'来添加新的条件
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( 'subscriber', $sign_on->roles ) ){
// Redirect users with subcriber role to a specific page.
$login_redirect = 'https://url';
GFCommon::log_debug( __METHOD__ . '(): Redirecting to ' . $login_redirect );
}else if ( in_array( 'customer', $sign_on->roles ) ){
// Redirect users with customer role to a specific page.
$login_redirect = 'https://url';
GFCommon::log_debug( __METHOD__ . '(): Redirecting to ' . $login_redirect );
}
return $login_redirect;
}
我从 GF 添加了这个功能,但我不知道如何在条件登录中添加另一个用户,有人可以帮忙吗:
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( 'subscriber', $sign_on->roles ) ){
// Redirect users with subcriber role to a specific page.
$login_redirect = 'https://url';
GFCommon::log_debug( __METHOD__ . '(): Redirecting to ' . $login_redirect );
}
return $login_redirect;
}
您可以简单地添加一个'else if'来添加新的条件
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( 'subscriber', $sign_on->roles ) ){
// Redirect users with subcriber role to a specific page.
$login_redirect = 'https://url';
GFCommon::log_debug( __METHOD__ . '(): Redirecting to ' . $login_redirect );
}else if ( in_array( 'customer', $sign_on->roles ) ){
// Redirect users with customer role to a specific page.
$login_redirect = 'https://url';
GFCommon::log_debug( __METHOD__ . '(): Redirecting to ' . $login_redirect );
}
return $login_redirect;
}