我目前正在为我的wordpress网站制作注册表单。我收到了这个错误
解析错误:语法错误,意外' {'在 C:\ XAMPP \ htdocs中\ WoodClef \可湿性粉剂内容\主题\ woodclef \ INC \ custormregform.php 第14行
以下是代码:
echo '<select name="role" class="input">';
foreach ( $wp_roles->roles as $key=>$value ) {
// Exclude default roles such as administrator etc. Add your own
if ( ! in_array( $value['name'], [ 'Administrator', 'Contributor', ] ) {
echo '<option value="'.$key.'">'.$value['name'].'</option>';
}
}
echo '</select>';
这里的第14行是
if ( ! in_array( $value['name'], [ 'Administrator', 'Contributor', ] ) {
如果我应该删除if语句,它可以工作,但我不想删除它。
以下是整个代码:
<?php
// How To create User Registration Form
//1. Add a new form element...
add_action( 'register_form', 'myplugin_register_form' );
function myplugin_register_form() {
global $wp_roles;
echo '<select name="role" class="input">';
foreach ( $wp_roles->roles as $key=>$value ) {
// Exclude default roles such as administrator etc. Add your own
if ( ! in_array( $value['name'], [ 'Administrator', 'Contributor', ] ) {
echo '<option value="'.$key.'">'.$value['name'].'</option>';
}
}
echo '</select>';
}
//2. Add validation.
add_filter( 'registration_errors', 'myplugin_registration_errors', 10, 3 );
function myplugin_registration_errors( $errors, $sanitized_user_login, $user_email ) {
if ( empty( $_POST['role'] ) || ! empty( $_POST['role'] ) && trim( $_POST['role'] ) == '' ) {
$errors->add( 'role_error', __( '<strong>ERROR</strong>: You must include a role.', 'mydomain' ) );
}
return $errors;
}
//3. Finally, save our extra registration user meta.
add_action( 'user_register', 'myplugin_user_register' );
function myplugin_user_register( $user_id ) {
$user_id = wp_update_user( array( 'ID' => $user_id, 'role' => $_POST['role'] ) );
}
答案 0 :(得分:2)
var rc = from site in customer.OrganizationSites
from gt in site.GeneralTransactions
where (gt.DealPackage.PackageTransactionDetail.StartDate <= periodStart
&& gt.DealPackage.PackageTransactionDetail.EndDate >= periodEnd)
|| (gt.DealPackage.PackageTransactionDetail.StartDate >= periodStart
&& gt.DealPackage.PackageTransactionDetail.EndDate <= periodEnd)
&& gt.IsVerified.HasValue
&& gt.IsVerified.Value
select gt;
rc = from gt in rc
where !gt.Invoices.Any()
|| !gt.Invoices.Any(i => i.StartDate >= periodStart && i.EndDate <= periodEnd)
select gt;
我相信你错过了一个')'......看起来好不好?
if ( ! in_array( $value['name'], [ 'Administrator', 'Contributor', ] ) {
其中有一个')'关闭if和one关闭“in_array”函数。