【问题标题】:Gravity Forms Wordpress: Redirect users role to a specific pageGravity Forms Wordpress:将用户角色重定向到特定页面
【发布时间】:2021-12-02 19:50:06
【问题描述】:

我从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;
}

【问题讨论】:

    标签: wordpress authentication gravityforms


    【解决方案1】:

    您可以简单地添加一个“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;
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-22
      • 2021-05-19
      • 2013-06-03
      • 1970-01-01
      • 2011-10-06
      • 1970-01-01
      相关资源
      最近更新 更多