Use the count shortcode inside a PHP function
-
Hi
I have a form (CF7) and the submissions are stored in CFDB. Is it possible to use the count shortcode inside a PHP function and compare the output number against another number to decide whether or not to show the form? What I’m looking for is to hide the form when the number of submissions >600. This is the function that I’ve tried:<?php $sumregistrations = <?php echo do_shortcode('[cfdb-count title="Registration"]'); ?>; if ($sumregistrations > 600 ): ?> //HIDE THE FORM <?php else : ?> //SHOW THE FORM <?php endif; ?>I got some advice from a guy at stackoverflow and first and foremost he said I can’t use a php function inside another php function. Secondly, he said:
…this shortcode outputs a string wrapped in HTML. Therefore, you cannot use it to compare against 600, as it will always return false. You should get the count value directly from the db table.
Can you give some advice on how to achieve what I’m looking for? Or is it not possible at all?
Thanks
The topic ‘Use the count shortcode inside a PHP function’ is closed to new replies.