Limit number of place

This topic contains 6 replies, has 3 voices, and was last updated by  Stiofan O’Connor 6 years, 7 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #417449

    TomFox
    Expired Member
    Post count: 41

    How can I limit the number of places a user can create?
    Unfortunately, I can’t go any further with the pricing manager.

    Best Regards

    Fox

    #417524

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    GeoDirectory uses the model that users receive free listings or paid listings, and that it is up to the site owner to make their own arrangements if they want to control access to the add-listing pages. In general the philosophy is that more listings are better, but if that is not the case for your site, then you can find a Member/Access management plugin that can suit your needs.

    Some members have mentioned S2 in the past, for controlling access to the Add Listing page.

    #417575

    TomFox
    Expired Member
    Post count: 41

    Actually, I don’t need pricing manager either and wouldn’t use an extensive plugin like s2member.
    Is there a hook for the Add Listing page?
    You could implement a limit function there.

    #417647

    Alex Rollin
    Moderator
    Post count: 27815

    I can point you at our doc about templates, and then flag your question for the developers to see if there is a quick fix.

    https://wpgeodirectory.com/docs/customizing-geodirectory-templates/

    #417732

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Fox,

    There is no setting to do this but you could do it with a small snippet (not tested, but something like)

    
    
    add_action('geodir_add_listing_form', '_my_geodir_action_add_listing_form_checks', 1);
    function _my_geodir_action_add_listing_form_checks(){
        $post_type_limit = 3;
        if(isset($_REQUEST['listing_type']) && $_REQUEST['listing_type']){
            $user_post_count = count_user_posts( get_current_user_id(), esc_attr($_REQUEST['listing_type']) );
            // check if the user has more or equal to number of posts as the limit.
            if($user_post_count >= $post_type_limit){
                // remove add listing form
                remove_action('geodir_add_listing_form', 'geodir_action_add_listing_form', 10);
               
                // add our own message
                echo "<h2>Sorry you are only allowed ".$post_type_limit." listings at most</h2>";
            }
        }
    }

    Thanks,

    Stiofan

    #418443

    TomFox
    Expired Member
    Post count: 41

    Hello Stiofan, I’ve caught a mean flu.
    As soon as I get well, I’ll look at a solution.
    Until then, love thanks.

    #418460

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    I read that as the “man flu”
    Get well soon! 🙂

Viewing 7 posts - 1 through 7 (of 7 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount