我的PHP知識有限,我需要更改表單中的字段 - 從強制到可選 - EMAIL FIELD
。將必填字段更改爲可選
下面是函數代碼:
function apostherapy_leads_form($options) {
$defaults = array(
'id' => 'frmLead' . rand(10, 99),
'title' => '',
'msg_success' => 'תודה רבה',
'msg_failure' => 'אירעה שגיאה. נא לנסות שוב. תודה',
'url' => 'http://leads.apostherapy.co.il/api/receiver.asp',
'campaign' => '',
'source' => get_bloginfo('name', 'display'),
'url_success' => '',
'url_failure' => '',
'placeholders' => false,
'with_join' => false,
'ajax' => true,
'label_name' => 'שם מלא',
'label_phone' => 'טלפון',
'label_email' => 'אימייל',
'label_join' => 'הנני מאשר קבלת חומר פרסומי מאפוסתרפיה',
'label_send' => 'שלח',
);
$defaults['name'] = $defaults['id'];
$options = !empty($options) ? array_merge($defaults, $options) : $defaults;
ob_start();
if (!empty($options['title'])): ?><h2><?= $options['title'] ?></h2><?php endif; ?>
<div class="leads<?php if ($options['ajax']): ?> ajax<?php endif; ?>">
<p class="success"><?= $options['msg_success'] ?></p>
<p class="failure"><?= $options['msg_failure'] ?></p>
<form id="<?= $options['id'] ?>" name="<?= $options['name'] ?>" action="<?= $options['url'] ?>" method="post">
<input type="hidden" id="nCampaignID" name="nCampaignID" value="<?= $options['campaign'] ?>">
<input type="hidden" id="sSource" name="sSource" value="<?= $options['source'] ?>">
<?php if (!empty($options['url_success'])): ?><input type="hidden" id="sSuccessRedirURL" name="sSuccessRedirURL" value="<?= $options['url_success'] ?>"><?php endif; ?>
<?php if (!empty($options['url_failure'])): ?><input type="hidden" id="sFailedRedirURL" name="sFailedRedirURL" value="<?= $options['url_failure'] ?>"><?php endif; ?>
<p>
<?php if (!$options['placeholders']): ?><label for="sFullName"><?= $options['label_name'] ?></label><?php endif; ?>
<input name="sFullName"<?php if (!$options['placeholders']): ?> id="sFullName"<?php endif; ?> type="text" value="" maxlength="30"<?php if ($options['placeholders']): ?> placeholder="<?= $options['label_name'] ?><?php endif; ?>">
</p>
<p>
<?php if (!$options['placeholders']): ?><label for="sPhone"><?= $options['label_phone'] ?></label><?php endif; ?>
<input name="sPhone"<?php if (!$options['placeholders']): ?> id="sPhone"<?php endif; ?> type="tel" value="" maxlength="11"<?php if ($options['placeholders']): ?> placeholder="<?= $options['label_phone'] ?><?php endif; ?>">
</p>
<p>
<?php if (!$options['placeholders']): ?><label for="sEmail"><?= $options['label_email'] ?></label><?php endif; ?>
<input name="sEmail"<?php if (!$options['placeholders']): ?> id="sEmail"<?php endif; ?> type="email" value="" maxlength="50"<?php if ($options['placeholders']): ?> placeholder="<?= $options['label_email'] ?><?php endif; ?>">
</p>
<p>
<input type="submit" class="clsButton" value="<?= $options['label_send'] ?>">
<?php if ($options['with_join']): ?><label for="sComments" class="join-newsletter"><input type="checkbox"checked='checked' name="sComments"<?php if (!$options['placeholders']): ?> id="sComments"<?php endif; ?> value="הירשם לניוזלטר קבל עדכונים למייל"><span><?= $options['label_join'] ?></span></label><?php endif; ?>
</p>
</form>
</div>
<?php
return ob_get_clean();
}
add_shortcode('leads_form', 'apostherapy_leads_form');
正如我所說的 - 我只是想電子郵件字段從強制改爲可選
我怎樣才能改變呢?
感謝
該字段是必填字段? –
也請包括處理html元素的代碼。那麼我們可以讓它成爲可選的。讓我們看看代碼 –
嗨 - 我更新了我的問題,包括完整的功能 - 我希望它能幫助你 - 謝謝 – Yaron123