Page 1 of 2 12 LastLast
Results 1 to 10 of 14
Like Tree2Likes

Thread: Hide Contact Form when Ad marked as SOLD

  1. #1
    Thread Starter
    compunetitcc's Avatar
    Join Date
    Nov 2012
    Location
    South Africa
    Posts
    162
    Thanks
    35
    Thanked 4 Times in 3 Posts

    Hide Contact Form when Ad marked as SOLD

    File: sidebar-contact.php
    CP:b 3.2.1

    Make Buckup of files first!

    When done you should not be able to see the Contact Form on Ads thats marked SOLD, but on other live ads the contact form will be visible.

    Just add a normal IF Statement with only 4 Lines of Code, Line 1,2,3,4 and last line closing the if

    PHP Code:
    <?php if(get_post_meta($post->ID'cp_ad_sold'true) == 'yes') : ?>
        <h3>Cannont Contact, Vehicle Sold</h3>

    <?php else : ?>

    <?php
        
    /**
     * This is the sidebar contact form used on the single ad page
     *
     */

    $msg '';

    // if contact form has been submitted, send the email
    if (isset($_POST['submit']) && $_POST['send_email'] == 'yes') {

        
    // get the submitted math answer
        
    $rand_post_total = (int)$_POST['rand_total'];

        
    // compare the submitted answer to the real answer
        
    $rand_total = (int)$_POST['rand_num'] + (int)$_POST['rand_num2'];

        
    // if it's a match then send the email
        
    if ($rand_total == $rand_post_total) {
            
    cp_contact_ad_owner_email($post->ID);
            
    $msg '<p class="green center"><strong>' __'Your message has been sent!'APP_TD ) . '</strong></p>';
        } else {
            
    $msg '<p class="red center"><strong>' __'ERROR: Incorrect captcha answer'APP_TD ) . '</strong></p>';
        }

    }

    ?>


       <form name="mainform" id="mainform" class="form_contact" action="#priceblock2" method="post" enctype="multipart/form-data">

           <?php echo $msg?>

           <p class="contact_msg"><?php _e'To inquire about this ad listing, complete the form below to send a message to the ad poster.'APP_TD ); ?></p>

            <ol>
                <li>
                    <label><?php _e'Name:'APP_TD ); ?></label>
                    <input name="from_name" id="from_name" type="text" minlength="2" value="<?php if(isset($_POST['from_name'])) echo esc_attrstripslashes($_POST['from_name']) ); ?>" class="text required" />
                    <div class="clr"></div>
                </li>

                <li>
                    <label><?php _e'Email:'APP_TD ); ?></label>
                    <input name="from_email" id="from_email" type="text" minlength="5" value="<?php if(isset($_POST['from_email'])) echo esc_attrstripslashes($_POST['from_email']) ); ?>" class="text required email" />
                    <div class="clr"></div>
                </li>

                <li>
                    <label><?php _e'Subject:'APP_TD ); ?></label>
                    <input name="subject" id="subject" type="text" minlength="2" value="<?php _e'Re:'APP_TD ); ?> <?php the_title();?>" class="text required" />
                    <div class="clr"></div>
                </li>

                <li>
                    <label><?php _e'Message:'APP_TD ); ?></label>
                    <textarea name="message" id="message" rows="" cols="" class="text required"><?php if(isset($_POST['message'])) echo esc_attrstripslashes($_POST['message']) ); ?></textarea>
                    <div class="clr"></div>
                </li>

                <li>
                    <?php
                    
    // create a random set of numbers for spam prevention
                    
    $randomNum '';
                    
    $randomNum2 '';
                    
    $randomNumTotal '';

                    
    $rand_num rand(0,9);
                    
    $rand_num2 rand(0,9);
                    
    $randomNumTotal $randomNum $randomNum2;
                    
    ?>
                    <label><?php _e'Sum of'APP_TD ); ?> <?php echo $rand_num?> + <?php echo $rand_num2?> =</label>
                    <input name="rand_total" id="rand_total" type="text" minlength="1" value="" class="text required number" />
                    <div class="clr"></div>
                </li>

                <li>
                    <input name="submit" type="submit" id="submit_inquiry" class="btn_orange" value="<?php _e'Send Inquiry'APP_TD ); ?>" />
                </li>

            </ol>

            <input type="hidden" name="rand_num" value="<?php echo $rand_num?>" />
            <input type="hidden" name="rand_num2" value="<?php echo $rand_num2?>" />
            <input type="hidden" name="send_email" value="yes" />

       </form>
    <?php endif; ?>
    samcy and dhenz123 like this.

  2. #2
    manamaga's Avatar
    Join Date
    May 2012
    Location
    United Kingdom
    Posts
    511
    Thanks
    9
    Thanked 14 Times in 13 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  3. #3
    manamaga's Avatar
    Join Date
    May 2012
    Location
    United Kingdom
    Posts
    511
    Thanks
    9
    Thanked 14 Times in 13 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  4. #4
    samcy's Avatar
    Join Date
    Mar 2012
    Location
    Germany
    Posts
    12,100
    Thanks
    121
    Thanked 1,756 Times in 1,442 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Rolf Hassel (Samcy)

  5. #5
    manamaga's Avatar
    Join Date
    May 2012
    Location
    United Kingdom
    Posts
    511
    Thanks
    9
    Thanked 14 Times in 13 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  6. #6
    manamaga's Avatar
    Join Date
    May 2012
    Location
    United Kingdom
    Posts
    511
    Thanks
    9
    Thanked 14 Times in 13 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  7. #7
    samcy's Avatar
    Join Date
    Mar 2012
    Location
    Germany
    Posts
    12,100
    Thanks
    121
    Thanked 1,756 Times in 1,442 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Rolf Hassel (Samcy)

  8. #8
    manamaga's Avatar
    Join Date
    May 2012
    Location
    United Kingdom
    Posts
    511
    Thanks
    9
    Thanked 14 Times in 13 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  9. #9
    bobyrou's Avatar
    Join Date
    Dec 2013
    Location
    United Kingdom
    Posts
    201
    Thanks
    16
    Thanked 9 Times in 6 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  10. #10
    samcy's Avatar
    Join Date
    Mar 2012
    Location
    Germany
    Posts
    12,100
    Thanks
    121
    Thanked 1,756 Times in 1,442 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Rolf Hassel (Samcy)

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [TUTORIAL] Hide contact tab is 'Sold"
    By manamaga in forum ClassiPress General Discussion
    Replies: 10
    Last Post: February 5th, 2013, 02:49 PM
  2. [SOLVED] marked as Sold ?
    By omerknet in forum Report ClassiPress Bugs
    Replies: 6
    Last Post: January 19th, 2013, 08:41 PM
  3. PHP help, hide pricetag when ad is marked "SOLD"
    By fraservalley in forum ClassiPress General Discussion
    Replies: 19
    Last Post: June 26th, 2012, 04:50 PM