[英]Hide content if function condition is met (PHP)
我有一個基於聯系表7的注冊表,當提交數量達到600時,我想隱藏它。我正在使用聯系表數據庫(CFDB)來存儲提交的數據,並且可以生成一個簡碼輸出提交的數量(以下稱為“ cfdb-count”)。
我正在使用Wordpress。
這是我嘗試過的,但是沒有用:
<?php
$sumregistrations = " . do_shortcode('[cfdb-count form="The reg form"]') . ";
if ($sumregistrations > 600 ){
// Hide the form
}else {
// Show the form
}
?>
編輯:這是此問題的有效解決方案:
<?php require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php');
$exp = new CFDBFormIterator();
$exp->export('NAME OF THE FORM', array('show' => 'submit_time', 'trans' => 'CountField(submit_time)'));
$count = 0;
while ($row = $exp->nextRow()) {
$count = $row['submit_time'];
}
if ($count > 600 ): ?>
//Content to show if number of submissions are greater than 600.
<?php else : ?>
//Content to show if number of submissions are less than 600.
//For example, show the form <?php echo do_shortcode('[contact-form-7 id="112" title="NAME OF THE FORM"]'); ?>
<?php endif; ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.