如何将自定义链接添加到WordPress登录页面?

时间:2013-05-13 作者:blackmetaluz

http://redrokk.com/wordpress/wp-content/uploads/2012/07/blank_wordpress_login_form1.png

我想在“丢失密码”之前添加自定义链接链接我目前正在使用一个带有css的函数来设置wordpress登录页面的样式(我没有单独的页面用于登录页面)。有什么想法吗?

3 个回复
SO网友:Core

嗯,你可以在丢失密码后添加链接,但我不认为你可以在丢失密码链接之前添加链接,除非你设计自己的登录页面。

function hook_lost_your_password ( $text ) {
        if ($text == \'Lost your password?\'){
            $text .= \'<br /><a href="http://codebing.com">Visit Code Bing</a>\';
        }
    return $text;
}
add_filter( \'gettext\', \'hook_lost_your_password\' );
来源:(Code Bing)

SO网友:David Senkus

很少有登录表单挂钩对您有用:

login_form AND login_footer
您可以在法典中找到更多关于它们的信息:Customizing_the_Login_Form#Login_Hooks

SO网友:Charles Clarkson

使用clean url 筛选以邪恶的方式添加新链接。

add_filter( \'clean_url\', \'wpse_99251_add_anchor_to_login_form\', 10, 2 );
/**
 * Add an anchor (link) to the login form.
 */
function wpse_99251_add_anchor_to_login_form( $good_protocol_url, $original_url ) {

    // Check to see if we are on the login page and escaping the "Lost Password?" url.
    if ( \'wp-login.php\' == $GLOBALS[\'pagenow\'] && $original_url == wp_lostpassword_url() ) {

        // If we get here, we are inside the href atribute of the lost password anchor.
        // So, the anchor we add starts in its middle.
        return sprintf(
            \'%s" title="%s">%s</a> | <a href="%s\',
            esc_url( \'https://my_link\' ),           // Change to your link url.
            esc_attr( \'My Link Title\' ),            // Change to your link title.
            \'My Link Name\',                         // change to your link name.
            $good_protocol_url
        );
    }

    return $good_protocol_url;
}

结束

相关推荐