Adding a checkbox to the ad submission
As a copy and paste programmer I am chuffed to share a mod that I just cracked and I am very pleased with myself. Steely eyed programmers will sniff at such things but I am not daunted. As yet, untainted by the trappings of success in the world of programming, I offer you:
How to put a check box item on your ad submission page.
I wanted a box, where registered traders will be asked to tick a box so that potential buyers know it's a trader or a regular punter. (I don't know whether it's a requirement in the UK but newspaper ads always come with a (T) printed on them in such cases, so I thought I better had too)
Anyway, of course, you can use it to your own end. Clearly, just change the variable 'trader' and the echoed text
(Note, line numbers are approximate, so be careful )
In Form_process.php
Insert the following around about line 31
Code:
if ( cp_filter($_POST['trader']) == "1") {
$trader="Yes";
} else {
$trader="No";
}
In post-form.php
Insert the following around about line 224
Code:
<div class="extrasbox">
<div style="margin: 10px 10px 10px 10px ;">
<span class="alignleft" ;"><input name="trader" value="1" type="checkbox" <?php if ($_POST['trader'] == '1') { echo "CHECKED";} ?> /></span>
<?php _e('Please tick the box if you are a trader','cp'); ?> <?php echo get_option('trader'); ?>
</div>
</div>
and Insert the following around about line 167
Code:
add_post_meta($post_id, 'trader', $trader, true);
In single.php
Insert the following around about line 44
Code:
<?php _e('Trader '); ?>: <?php echo get_post_meta($post->ID, "trader", true); ?>
After spending the last three weeks tweaking this theme out of site, I am feeling very pleased with myself.
I hope it's useful to someone.