• Hello,

    I want to create ad space scarcity in my marketplace.

    1. Please how can I limit the overall ad space available to only 200 ads in my marketplace. Once my marketplace has 200 ads users cannot lists ads again. If a user tries to advertise by going to [advert-add] page they are automatically redirect to a custom page (overall-ad-limit-reached)

    A simple redirect function would work that is, when ads = 200 listings redirect [advert-add] page to custom page (overall-ad-limit-reached) page.

    2. Shortcode to display total ad space remaining e.g (50 Ad spaces available out of 200)

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    1. you can redirect the user to some other page from the page with [adverts_add] shortcode with the below code

    
    add_action( "template_redirect", function( $t ) {
      if( ! is_page( 1000 ) ) {
        return $t;
      }
      if( wp_count_posts( 'advert' )->publish >= 200 ) {
        wp_redirect( "https://url/to/info/page" );
        exit;
      }
      return $t;
    } );
    

    You would need to replace 1000 with the actual ID of the page where you are using the [adverts_add] shortcode and the https://url/to/info/page with the actual URL you want to redirects the users to.

    2. the number of currently active Ads (visible on page) you can get with wp_count_posts( 'advert' )->publish code, see https://developer.www.ads-software.com/reference/functions/wp_count_posts/ for more details.

    Thread Starter teeboy4real

    (@teeboy4real)

    Thanks please can you modify the code to only accept 200 Ads with status as (PUBLISHED) and exclude count of drafts and expired ads

    Thread Starter teeboy4real

    (@teeboy4real)

    Also, I need another redirect code similar as above code to prevent users from renewing ads when 200 ads are currently published and active.

    When user goes to [advert_manage] and clicks (renew ad) button
    redirect advert renew page to custom page (overall-ad-limit-reached)

    Example – when active published ads = 200
    redirect https://www.website.com/manage-listings/?advert_renew=35787 to (overall-ad-limit-reached) page

    Thanks

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    i am afraid the customizations like that are far beyond the support offered here, you would need some developer that will create this functionality for you, sorry.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Limit overall ad space’ is closed to new replies.