重定向登录返回主页

时间:2014-01-08 16:18:52

标签: php wordpress wordpress-plugin phpbb phpbb3

我正在使用WordPress和phpBB以及一个名为wp-united的插件。我试图让用户重定向回我博客的主页而不是论坛。我尝试过更改,但没有成功,所以我删除了我的更改。

以下是当前代码:

    get_currentuserinfo();
$loggedIn = $phpbbForum->user_logged_in();

$loginLang = ($loggedIn) ? sprintf($phpbbForum->lang['LOGOUT_USER'], $phpbbForum->get_username()) : $phpbbForum->lang['LOGIN'];
$loginAction = ($loggedIn) ? '?mode=logout' : '?mode=login';


if($loggedIn) {
    $wpu_usr = get_wpu_phpbb_username(); 
    $colour = $phpbbForum->get_userdata('user_colour');
    $colour = ($colour) ? ' style="color: #' . $colour . '" ' : '';
    $ret .= _wpu_add_class($before, 'wpu-widget-lu-avatar') . '<img src="' . get_avatar_reader() . '" alt="' . $phpbbForum->lang['USER_AVATAR'] . '" />' . $after; 
    $ret .= _wpu_add_class($before, 'wpu-widget-lu-username'). '<a href="' . $phpbbForum->get_board_url() . 'ucp.' . $phpEx . '" ' . $colour . '><strong>' . $wpu_usr . '</strong></a>' . $after;

    if ( $showRankBlock ) {
        $ret .= _wpu_add_class($before, 'wpu-widget-lu-rankblock') . get_wpu_phpbb_rankblock() . $after;
    }
$ret .= _wpu_add_class($before, 'wpu-logout') . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . 'ucp.' . $phpEx . $loginAction) . '" title="' . $loginLang . '">' .  $loginLang . '</a>' . $after;
} else {
    if ( $showLoginForm ) {
        $redir = wpu_get_redirect_link();
        $login_link = $phpbbForum->append_sid('ucp.'.$phpEx.'?mode=login') . '&amp;redirect=' . $redir;
        $ret .= '<form class="wpuloginform" method="post" action="' . $phpbbForum->get_board_url() . $login_link . '">';
        $ret .= $before . '<label for="phpbb_username">' . $phpbbForum->lang['USERNAME'] . '</label> <input tabindex="1" class="inputbox autowidth" type="text" name="username" id="phpbb_username"/>' . $after;
        $ret .= $before . '<label for="phpbb_password">' . $phpbbForum->lang['PASSWORD'] . '</label> <input tabindex="2" class="inputbox autowidth" type="password" name="password" id="phpbb_password" maxlength="32" />' . $after;
        if ( $autoLogin ) {
            $ret .= $before . '<input tabindex="3" type="checkbox" id="phpbb_autologin" name="autologin" /><label for="phpbb_autologin"> ' . __('Remember me', 'wp-united') . '</label>' . $after;
        }
        $ret .= $before . '<input type="submit" name="login" class="wpuloginsubmit" value="' . __('Login') . '" />' . $after;
        $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url()."ucp.php?mode=register") . '">' . __('Register', 'wp-united') . '</a>' . $after;
        $ret .= $before . '<a href="'. $phpbbForum->append_sid($phpbbForum->get_board_url().'ucp.php?mode=sendpassword') . '">' . __('Forgot Password?', 'wp-united') . '</a>' . $after;
        $ret .= '</form>';
    } else {
        $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . 'ucp.' . $phpEx . $loginAction) . '" title="' . $loginLang . '">' .  $loginLang . '</a>';
    }
}
/**
 * Returns a URL suitable for sending as a redirect instruction to phpBB
  * @ since v0.8.1
*/
function wpu_get_redirect_link() {
global $phpbbForum;
if(!empty( $_SERVER['REQUEST_URI'])) {
    $protocol = empty($_SERVER['HTTPS']) ? 'http:' :     ((strtolower($_SERVER["HTTPS"]) == 'on') ? 'https:' : 'http:');
    $protocol = ($_SERVER['SERVER_PORT'] == '80') ? $protocol : $protocol .  $_SERVER['SERVER_PORT'];
    $link = $protocol . '//' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
} else {
    $link = get_option('home');
}
$fStateChanged = $phpbbForum->foreground();
$link = reapply_sid($link);
$phpbbForum->restore_state($fStateChanged);
return urlencode(esc_attr($link));
}

0 个答案:

没有答案