我创建一个自定义注册表单在wordpress买我有以下错误,我似乎找不到什么导致他们。
注意:未定义的变量:new_user在第219行的 /Applications/MAMP/htdocs/****/wp-内容/插件/护理匹配/carematch.php
注意:未定义的变量:错误 /Applications/MAMP/htdocs/****/wp-内容/插件/护理匹配/carematch.php行233
carer-registration.php
<?php get_header();
// Template Name: Carer Registration
?>
<div id="main-content">
<div class="container">
<div class="row">
<div class="col-md-12">
<?php do_action('carer_registration'); ?>
<form method="POST" id="add-carer" class="user-forms" action="">
<strong>Name</strong>
<p class="first-name">
<label for="first-name"><?php echo 'Firstname (required)'; ?></label>
<input class="text-input" name="first-name" type="text" id="first-name" value="" />
</p>
<p class="surname">
<label for="surname"><?php echo 'Surname (required)'; ?></label>
<input class="text-input" name="surname" type="text" id="surname" value="" />
</p>
<p class="first-line">
<label for="first-line"><?php echo 'First line (required)'; ?></label>
<input class="text-input" name="first-line" type="text" id="first-line" value="" />
</p>
<p class="town-city">
<label for="town-city"><?php echo 'Town/City (required)'; ?></label>
<input class="text-input" name="town-city" type="text" id="town-city" value="" />
</p>
<p class="county">
<label for="county"><?php echo 'County (required)'; ?></label>
<input class="text-input" name="county" type="text" id="county" value="" />
</p>
<p class="postcode">
<label for="email"><?php echo 'Postcode (required)'; ?></label>
<input class="text-input" name="postcode" type="text" id="postcode" value="" />
</p>
<p class="mobile">
<label for="mobile"><?php echo 'Mobile (required)'; ?></label>
<input class="number-input" name="postcode" type="number" id="mobile" value="" />
</p>
<p class="email">
<label for="email"><?php echo 'Email Address (required)'; ?></label>
<input class="email-input" name="email" type="email" id="email" value="" />
</p>
<p class="form-submit">
<input name="adduser" type="submit" id="adduser" class="submit button" value="Register" />
</p>
</form>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
functions.php
//PROCESS CARER REGISTRATION FORM
function process_carer_registration() {
if (isset($_POST['add-carer'])) {
echo "success";
$user_pass = wp_generate_password();
$userdata = array(
'user_pass' => $user_pass,
'first-name' => esc_attr( $_POST['first-name'] ),
'surname' => esc_attr( $_POST['surname'] ),
'first-line' => esc_attr( $_POST['first-line'] ),
'town-city' => esc_attr( $_POST['town-city'] ),
'county' => esc_attr( $_POST['county'] ),
'postcode' => esc_attr( $_POST['postcode'] ),
'mobile' => esc_attr( $_POST['mobile'] ),
'email' => esc_attr( $_POST['email'] ),
'user_login' => esc_attr( $_POST['first-name'] . $_POST['surname'] . rand(1000,9999) ),
'role' => get_option( 'carer' ),
);
if ( !$userdata['first-name'] )
$error = 'Please enter your first name';
elseif ( !$userdata['surname'] )
$error = 'Please enter your surname';
elseif ( !$userdata['first-line'] )
$error = 'Please enter the first line of your address';
elseif ( !$userdata['town-city'] )
$error = 'Please enter your town/city';
elseif ( !$userdata['county'] )
$error = 'Please enter your county';
elseif ( !$userdata['postcode'] )
$error = 'Please enter your postcode';
elseif ( !$userdata['mobile'] )
$error = 'Please enter your mobile phone number';
elseif ( !is_email($userdata['email'], true) )
$error = 'You must enter a valid email address.';
elseif ( email_exists($userdata['email']) )
$error = 'Sorry, that email address is already in use';
// setup new users and send notification
else {
$new_user = wp_insert_user( $userdata );
wp_new_user_notification($new_user, $user_pass);
}
}
if ( $new_user ) : ?>
<p class="alert">
<?php
$user = get_user_by('id',$new_user);
echo 'Thank you for registering ' . $user->first-name;
echo '<br/>Please check your email inbox. That\'s where you\'ll recieve your login password.<br/> (Be sure to check your spam folder)';
?>
</p>
<?php else : ?>
<?php if ( $error ) : ?>
<p class="error">
<?php echo $error; ?>
</p>
<?php endif; ?>
<?php endif;
}
add_action('carer_registration', 'process_carer_registration');
您可以使用isset()
函数来摆脱此错误
此行if($new_user):?
和
在函数顶部,添加$new\u user=null
和$error=null
这样,当这些变量未定义时,下面的条件就不会发出警告。
function process_carer_registration() {
$new_user = null;
$error = null;
本文向大家介绍WordPress 注册自定义帖子类型,包括了WordPress 注册自定义帖子类型的使用技巧和注意事项,需要的朋友参考一下 示例 假设您有一个图书馆网站,并且想要一个名为Books的自定义帖子类型。可以注册为 如此简单,您现在就注册了一个自定义帖子类型。 该代码段可以放在主题functions.php文件中,也可以放在插件结构中。
我想注册一个Avro模式,它在模式注册表上引用另一个Avro模式。 首先,我注册了以下基本Avro模式: 如果我尝试注册以下Avro架构,该架构引用“客户端”属性中的基本架构,则操作失败并出现错误422 这个问题似乎与指定自定义类型字段有关。 任何想法如何添加自定义类型,同时注册相关的模式在模式注册表?
我是新来的Laravel。我有两种不同的用户类型:老师和学生。教师在网站注册表格中注册账户,但学生注册由windows应用程序提供。所以我必须为这个应用程序提供一个API。默认Laravel认证是足够的教师注册,但我可以使用相同的AuthController API注册?我不需要视图或重定向到网站。
我已经为log4j2编写了一个自定义触发策略,该策略将被回滚。在每小时/天/你的工作时间间隔结束时,按照本SO帖子的建议记录文件。 虽然我遵循基于时间的触发策略约定(命名等),但我无法看到我的策略被实例化和使用。 解决方案由3个java文件和一个maven文件组成,可在github上获得 在这里,您可以从政策本身找到主要内容: log4j2。xml文件: 编辑: 在调试过程中,我了解到在log4j
问题内容: 我有一个网站,有一个用户系统。我想将wordpress的用户系统集成到该网站的系统中,但是我仍然想使用该网站的注册/登录页面。我不希望任何人都能使用Wordpress的登录或注册表格进行登录或注册。相反,当他们尝试访问Wordpress中的登录/注册页面时,我希望这些页面将它们重定向到我自己的登录/注册页面。 有什么办法吗?我已经尝试过Google,但是我所能找到的只是在用户登录或注册
我已经创建了一个包含多个分类法的自定义查询,在此基础上,我使用进行分页。分类法是通过下拉选择表单来选择的,使用可以过滤帖子,这只是一个临时解决方案,但目前效果良好,值得注意。 分页工作正常,当选择分类术语时,帖子可以正确显示,但是当我离开第一页,比如说我进入第2页,在下拉选择器中选择不同的分类术语时,URL会保留当前页码,并向其中添加选择器ID。我想实现的是,当我在选择器中单击不同的分类法时,新选