链接到 Wordpress 中的注册页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5191618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:44:09  来源:igfitidea点击:

Link to registration page in Wordpress

wordpress

提问by Captain Comic

There is

wp_login_url, wp_logout_url, but what what about registration url?

wp_login_url, wp_logout_url, 但是注册网址呢?

Is there standard way to get link to registration? I need to display a link to registration page with further redirect to previous page.

有没有标准的方法来获取注册链接?我需要显示一个指向注册页面的链接,并进一步重定向到上一页。

PS I am using my theme login.

PS 我正在使用我的主题登录

回答by johnhunter

The following will return the registration url:

以下将返回注册网址:

<?php

    echo site_url('/wp-login.php?action=register');

?>

UPDATE:

更新:

To get the registration url with a redirect to the current page use:

要通过重定向到当前页面获取注册 url,请使用:

<?php

    echo site_url('/wp-login.php?action=register&redirect_to=' . get_permalink());

?>

回答by Jake

Since 3.6, there is now a func: http://codex.wordpress.org/Function_Reference/wp_registration_url

从 3.6 开始,现在有一个 func:http: //codex.wordpress.org/Function_Reference/wp_registration_url

<?php echo wp_registration_url(); ?>

You can override it with the register_urlfilter.

您可以使用register_url过滤器覆盖它。

add_filter( 'register_url', 'custom_register_url' );
function custom_register_url( $register_url )
{
    $register_url = get_permalink( $register_page_id );
    return $register_url;
}

回答by Mark

I know this is an old question, but for anyone picking it up use wp_register().

我知道这是一个老问题,但对于任何拿起它的人来说,请使用wp_register()

It automatically determines if you're logged in and supplies either a link to the admin section of the site, or a link to the register form.

它会自动确定您是否已登录并提供指向站点管理部分的链接或指向注册表的链接。

It also respects the settings in Settings -> General -> Membership (Anyone Can Register?)

它还尊重设置 -> 常规 -> 会员资格(任何人都可以注册?)

回答by papaiatis

In case of hosting your wordpress site in a subfolder (e.g.: mysite.com/myblog) you also need to include your site's url as follows:

如果将您的 wordpress 网站托管在子文件夹(例如:)中,mysite.com/myblog您还需要包含您网站的网址,如下所示:

<?php echo get_site_url() . "/wp-login.php?action=register" ?>

<?php echo get_site_url() . "/wp-login.php?action=register" ?>

--> http://mysite.com/myblog/wp-login.php?action=register

--> http://mysite.com/myblog/wp-login.php?action=register

Otherwise you will be redirected to a non-existing page

否则你将被重定向到一个不存在的页面

--> http://mysite.com/wp-login.php?action=register

--> http://mysite.com/wp-login.php?action=register

回答by Betty

If I understand correctly you are asking for default Word Press registration page. That would be www.domainname.com/wp-signup.php

如果我理解正确,您要求的是默认的 Word Press 注册页面。那将是www.domainname.com/wp-signup.php

回答by Eran Carmon

1st of all I'm a WP newbe.

首先,我是 WP 新手。

wp_registration_url can redirect the new user back to the page he came from, buy without enforcing login on the way (I dont use auto login because i want the user to authenticate the mail).

wp_registration_url 可以将新用户重定向回他来自的页面,购买时无需强制登录(我不使用自动登录,因为我希望用户对邮件进行身份验证)。

i use instead (sample with Allow PHP in posts plugin):

我改用(在帖子插件中使用允许 PHP 的示例):

<a href="[php]echo site_url('/wp-login.php?action=register&redirect_to=/wp-login.php?redirect_to=' . get_permalink());[/php]" title="Register">Register</a>

hope it helps...

希望能帮助到你...

回答by Talha

You can use wp_registration_url() any where you want to add link to wordpress registration to add the redirection url use apply_filters()

您可以使用 wp_registration_url() 任何要添加到 wordpress 注册链接的位置来添加重定向 url 使用 apply_filters()

<a href="<?php wp_registration_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ); ?>" >click to register</a>

回答by VeecoTech

2 points here

2分在这里

  1. Make sure you have turn on the "Anyone can register" in the setting page
  2. if you host in a subfolder, make sure you include
  1. 确保您在设置页面中打开了“任何人都可以注册”
  2. 如果您在子文件夹中托管,请确保包含

Without subfolder:

没有子文件夹:

<a href="/wp-login.php?action=register">Register</a>

OR

或者

<a href="<?php echo wp_registration_url(); ?>">Register</a>

With subfolder

带子文件夹

<a href="shop/wp-login.php?action=register">Register</a>