(Technical question)- How to limit the number of page views for a specific site under a WPMU instsal

Hello,

Existing WPMU plugins provide for site limits to be set on space and bandwidth-- as I plan to use a CDN for the images/videos (ie the content that uses up most of space+bandwidth)-- I wish to approach the issue of limiting usage of a single site within a WPMU install in a different way-- by counting the number of page views for that site in a single month.

Kindly let me know exactly what I have to do to count the page views for a site-- is this (access to all pages within a site) stored somewhere? Or is there some way to create a plugin that logs each such page view (or 'hit') to a website?

I have no problem programming the solution- the question is how to count the number of page views for a single site.

Another issue- I would like that site to be automatically suspended once the number of hits reaches a certain level-- for eg if a blog is only allowed 10,000 page views in a month- then after the 10,000th view, when the next viewer attempts to view that blog he should get a generic "Site Suspended because it has reached its usage limits" (or some such) message. What I want to know is, what is the quickest way to display such a message (irrespective of any page being accessed- as long as the max number of page views for that site have been used up and the page being accessed belongs to that site-that page can be a blog post/a marketpress page//a page belonging to any Wordpress module/plugin that is installed on that specific site). I wish to 'suspend' a single site in the easiest manner possible programmatically( I would prefer not to do this manually by logging in as WPMU Superadmin)-- is such functionality already there in ProSites (but used when the space/bandwidth limits of a user are reached)? Please let me know if this is so (as it would be easiest to use such working and tested code- only now it would work to limit number of page views).

Thanks,
Arvind.

  • Alexander
    • DEV MAN’s Mascot

    Hello @Arvind,

    I've looked around and I can't find anything that will do what you're asking specifically. However, if you're open to coding it yourself, I have some advice to offer. Taking both of your issues into account, here's some thoughts I have on tackling this.

    I would recommend starting with Pro Sites. You can easily create your own modules to extend it. For a good starting point, you could copy from the "Upload Quota" module. Then take a look at the "Pay to Blog" module - it's the one that suspends if a payment hasn't been made, so that can give you head start for suspending once the view limit is reached.

    To track the page hits, the simplest thing would be setting up a hook to call get_site_option when the page is loaded, then update the value using update_site_option. And while you have that value out of the database, in the same function you could place the code to see if it's time to suspend the site.

    Does this answer all your questions ok? Let me know if you need anything else.
    Best regards,
    Alexander Rohmann

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.