Wordpress用户链接提交
所以我想做的是:在一个页面上有一个提交字段,用户可以提交一个链接,成功提交后,用户将被重定向到注册页面,成功注册后,他先前提交的链接将出现在他的个人资料上。这怎么可能?有没有这样的插件?丹!什么都行 流程如下所示:Wordpress用户链接提交,wordpress,form-submit,registration,profile,Wordpress,Form Submit,Registration,Profile,所以我想做的是:在一个页面上有一个提交字段,用户可以提交一个链接,成功提交后,用户将被重定向到注册页面,成功注册后,他先前提交的链接将出现在他的个人资料上。这怎么可能?有没有这样的插件?丹!什么都行 流程如下所示: 创建自定义注册页面 带有链接提交表单的页面会将$\u POST发送到自定义注册页面 注册页面从$\u POST读取提交链接的值,并预填充字段 当用户提交注册页面时,使用wp\u user\u create和add\u user\u meta功能设置配置文件 我认为使用插件是过分的,特
$\u POST
发送到自定义注册页面$\u POST
读取提交链接的值,并预填充
字段wp\u user\u create
和add\u user\u meta
功能设置配置文件<?php
/**
* Template Name: Custom registration
*/
// If the link info is missing, go back to the link submission page
$link = false;
if (!isset($_POST['user_submitted_link']) || !isset($_POST['user_link'])) {
wp_redirect('/link-submission-page');
} else {
$link = isset($_POST['user_submitted_link']) ? $_POST['user_submitted_link'] : $_POST['user_link'];
}
// If the registration form was submitted
// the $_POST['user_link'] will be set and we can
// register the user
if (isset($_POST['user_link'])) {
$new_user = wp_create_user($_POST['email'], $_POST['password'], $_POST['email']);
if ($new_user) {
add_user_meta($new_user, 'user_link', $_POST['user_link']);
// User account is created, you can redirect to login or do whatever here
}
}
// Render the registration form if we have a $link
if ($link) : ?>
<form action="<?php the_permalink(); ?>" method="POST">
<input type="email" name="email">
<input type="password" name="password">
<input type="hidden" name="user_link" value="<?= $_POST['user_submitted_link']; ?>">
<button>Register</button>
</form>
<?php endif;
谢谢我已经开始做了。如果我以后有其他问题,我可以问你吗?