View Poll Results: What do you think of this mod/tutorial? (sorry I'm getting less creative with my options)

Voters
4. You may not vote on this poll
  • Too hard for me to use.

    1 25.00%
  • I'm gonna try it, but who knows if it will work.

    0 0%
  • Its perfect and I love it!

    3 75.00%
Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Free Ads Renewal Ability Mod

  1. #1
    Community Partner scarstens's Avatar
    Join Date
    Apr 2010
    Location
    Cave Creek, AZ USA
    Posts
    912
    Thanks
    2
    Thanked 129 Times in 86 Posts

    Free Ads Renewal Ability Mod

    Phew, I'm pretty wiped for the mods today so I'm gonna try to make this quick...

    This mod to going to "enable" your posters to renew there free ads from the dashboard after the ads expire, regardless if they get an email or not. Please do keep in mind if you have ad pruning on that it could "delete" the ad before they are able to renew it so I would suggest something like 365 days on pruning, or something 30 days longer then your longest ad pack length.That being said, lets begin.

    Step 1: Modifying the tpl-dashboard.php file to allow our free ads to be relisted. Also in this step I'll be modifying the page slightly so you get a message at the top when you "pause" and "resume" ad listings.

    FIND:
    Code:
        if($checkauthor != null) { // author check is ok. now update ad status
    Now I need you to "erase all the code" in the IF STATEMENT. It ends near the "else { //echo "nothing here" }. When you are done the code will look like this:
    Code:
        if($checkauthor != null) { // author check is ok. now update ad status
    
        }
    
    endif;
    Next we are going to replace the code we just erased. So take the code below and paste it inside the IF STATEMENT, where the previous code used to be.
    Code:
            if ($d == 'pause') {
                $my_ad = array();
                $my_ad['ID'] = $aid;
                $my_ad['post_status'] = 'draft';
                wp_update_post($my_ad);
    			$pagemessage = 'Paused ad with ID: ' . $aid;
            } 
    		elseif ($d == 'restart') {
                $my_ad = array();
                $my_ad['ID'] = $aid;
                $my_ad['post_status'] = 'publish';
                wp_update_post($my_ad);
    			$pagemessage = 'Resumed ad with ID: ' . $aid;
            } 
    		elseif ($d == 'freerenew') {
                $my_ad = array();
                $pagemessage = cp_renew_ad_listing($aid);
            }
    		else {
                //echo "nothing here";
            }
    -----------------------------------------------------------------------------------------------------------------------
    Still on the same page we are now going to modify the next section.
    Next find the following code:
    Code:
    <?php _e('Below you will find a listing of all your classified ads. Click on one of the options to perform a specific task. If you have any questions, please contact the site administrator.','cp');?></p>
    ADD A NEW LINE OF CODE AND INSERT THE FOLLOWING:
    Code:
    <?php if(isset($pagemessage)) echo '<div class="pagemessage">' . $pagemessage . '</div>'; ?>


    Okay next we are going to find:
    Code:
    if (get_option('cp_allow_relist') == 'yes') {
    Found it? Okay now we are going to look for the FIRST OF TWO "echo '&mdash;';"
    Lets replace the first one with the following code instead:
    Code:
    echo 'Free Ad Renewal';
    Just to be clear when your done these lines of the page should look something like this:
    Code:
                                            } else { 
    
    											echo 'Free Ad Renewal';
                                            }
    
                                        } else {
    
                                            echo '&mdash;';
    
                                        }

    I'm exhausted... how about you? We are almost done though and the next one is really easy. Now you might be asking "what if they try to relist a paid advertisement using this type of link?" and don't worry the code will not allow them to relist of the advertisement cost them anything. This has already been tested.

    So last thing we are going to do is open up the (functions.php) page.
    Find this code:
    Code:
    /**
    
     * add any of your custom functions below this section
    
     */
    As the code indicates, lets place our new function below that section. Here is the code you want to paste beneath that code segment above.
    Code:
    function cp_renew_ad_listing ( $ad_id )
    {
    	$listfee = (float)get_post_meta($ad_id, 'cp_sys_total_ad_cost', true);
    	if ($listfee == 0)
    	{
    		$ad_length = get_post_meta($ad_id, 'cp_sys_ad_duration', true);
            if(isset($ad_length))
                $ad_length = $ad_length;
            else
                $ad_length = get_option('cp_prun_period');
    
            // set the ad listing expiration date
            $ad_expire_date = date('m/d/Y H:i:s', strtotime('+' . $ad_length . ' days')); // don't localize the word 'days'
    
            //now update the expiration date on the ad
            update_post_meta($ad_id, 'cp_sys_expire_date', $ad_expire_date);
    		return 'Advertisement Renewed and will now expire on: ' . $ad_expire_date . '. The renewed ad has been paused, you can edit the ad or reduce the price before resuming the ad. Do not forget that you ad will not be live until you click the resume button in the ad options column.';
    	}
    	else //attempt to relist a paid ad
    	{
    		return 'You cannot relist this using this function, most likely the ad must be relisted by using the paypal link.';
    	}
    }
    Now lets just pray that they consider my modification in the next update so we don't have to do this again!
    ~ Seth Carstens, Sethmatics Inc.


  2. #2
    Senior Member netpotion's Avatar
    Join Date
    Feb 2010
    Location
    United States
    Posts
    246
    Thanks
    30
    Thanked 13 Times in 10 Posts

    Re: Free Ads Renewal Ability Mod

    You must be an AppThemes customer and logged in to view this response. Join today!
    My Currently Live Sites
    ~ http://www.netpotion.com - Free Flash Gamez
    ~ http://www.picdepict.com - Free Image Hosting

  3. #3
    Community Partner scarstens's Avatar
    Join Date
    Apr 2010
    Location
    Cave Creek, AZ USA
    Posts
    912
    Thanks
    2
    Thanked 129 Times in 86 Posts

    Re: Free Ads Renewal Ability Mod

    You must be an AppThemes customer and logged in to view this response. Join today!
    ~ Seth Carstens, Sethmatics Inc.


  4. #4
    Veteran rodeoramsey's Avatar
    Join Date
    Jan 2010
    Location
    Ohio
    Posts
    277
    Thanks
    3
    Thanked 13 Times in 10 Posts

    Re: Free Ads Renewal Ability Mod

    You must be an AppThemes customer and logged in to view this response. Join today!
    ~Ramsey

  5. #5
    Community Partner scarstens's Avatar
    Join Date
    Apr 2010
    Location
    Cave Creek, AZ USA
    Posts
    912
    Thanks
    2
    Thanked 129 Times in 86 Posts

    Re: Free Ads Renewal Ability Mod

    You must be an AppThemes customer and logged in to view this response. Join today!
    ~ Seth Carstens, Sethmatics Inc.


  6. #6
    Veteran rodeoramsey's Avatar
    Join Date
    Jan 2010
    Location
    Ohio
    Posts
    277
    Thanks
    3
    Thanked 13 Times in 10 Posts

    Re: Free Ads Renewal Ability Mod

    You must be an AppThemes customer and logged in to view this response. Join today!
    ~Ramsey

  7. #7
    Community Partner scarstens's Avatar
    Join Date
    Apr 2010
    Location
    Cave Creek, AZ USA
    Posts
    912
    Thanks
    2
    Thanked 129 Times in 86 Posts

    Re: Free Ads Renewal Ability Mod

    You must be an AppThemes customer and logged in to view this response. Join today!
    Last edited by pepsi; July 9th, 2010 at 12:52 AM.
    ~ Seth Carstens, Sethmatics Inc.


  8. #8
    Member stefan's Avatar
    Join Date
    Jan 2010
    Location
    Hamburg Germany
    Posts
    73
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Free Ads Renewal Ability Mod

    You must be an AppThemes customer and logged in to view this response. Join today!

  9. #9
    Community Partner scarstens's Avatar
    Join Date
    Apr 2010
    Location
    Cave Creek, AZ USA
    Posts
    912
    Thanks
    2
    Thanked 129 Times in 86 Posts

    Re: Free Ads Renewal Ability Mod

    You must be an AppThemes customer and logged in to view this response. Join today!
    Last edited by pepsi; July 9th, 2010 at 12:52 AM.
    ~ Seth Carstens, Sethmatics Inc.


  10. #10
    Founder dcowgill's Avatar
    Join Date
    Mar 2009
    Location
    San Francisco, CA
    Posts
    1,939
    Thanks
    66
    Thanked 135 Times in 99 Posts

    Re: Free Ads Renewal Ability Mod

    You must be an AppThemes customer and logged in to view this response. Join today!

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. Free or Paid Classifieds
    By sarge in forum ClassiPress General Discussion
    Replies: 0
    Last Post: June 24th, 2009, 04:53 PM