Support forums > Plugins

Limiting number of postings per user (solved)

(1/2) > >>

BritWeb:
Hi

Is there a way to limit number of postings per user? Ideally I do not want an Estate agent to post every one of his property listings.

I would like to limit the number of listings to two for a member.

Thanks

teseo:
***CORRECTED***

Hi,

Well, first you need to tick "Only logged in users can post listings" on Admin Dashboard / Listings / Settings.

Then insert this almost at the top of your theme item-post.php (after the initial comments and before // meta tag robots):


--- Code: ---if (osc_is_publish_page()) {
$limit = 2;
if (osc_user_field('i_items') >= $limit) {
    osc_add_flash_error_message(sprintf(_m("You can't post more than %d listings"), $limit));
    header("Location: " . osc_base_url());
    exit;
}
}

--- End code ---

Change the value of $limit variable if you want to allow more (or less, only one ad per user).

Regards

BritWeb:
Many thanks, teseo

Just to take it a step further, how can we set limit to number of listings separately for companies and individuals.?

Thank you once again.

teseo:
***CORRECTED***

Hi,


--- Code: ---if (osc_is_publish_page()) {
    $limits = array(2, 10); // (Individual, Company)
    $current_limit = $limits[osc_user_field("b_company")];

    if (osc_user_field('i_items') >= $current_limit) {
        osc_add_flash_error_message(sprintf(_m("You can't post more than %d listings"), $current_limit));
        header("Location: " . osc_base_url());
        exit;
    }
}

--- End code ---

Regards

BritWeb:
Great! Thank you, teseo

Much appreciated! Kind regards

Navigation

[0] Message Index

[#] Next page

Go to full version