How does prosite get to know file space used?

Hi Guys!

Hope everything is going great and you are creating state of the art plugins like you always do :slight_smile:

I have a small question if you can help me out. I am trying to build a wp-admin end dashboard area (that displays on the /wp-admin main page when you login). It lists the Blog title, Username , firstname , The level of the user (interms of Prosites) AND how much disk space has been used by him from his allotted quota.

There is a setting in prosites where you can set a limit on how much disk space is allowed for a particular level. Hence there must be a function or a check somewhere to see how much of this has been used.

I want to use that check (call the function) and display how much of it has been used in the admin dashboard area that I am creating.

If you signup on edublogs, you can see that area in the dashboard that displayes this information. I want something like that which is almost complete. Just need this final piece on info.

Many Thanks!
Keep up the good work!
Mindblazetech

  • Alexander
    • DEV MAN’s Mascot

    Hello @Mindblazetech,

    This is done using the "Upload Quota" module. If you head over to "Modules / Gateways" from the Pro Sites menu, then take a look at the very last one on the list. After you enable the upload quota, you can configure the limits for each level from it's settings section on the main Pro Sites settings page. You'll also be able to configure an upsell message, and out-of-space message.

    Hope this helps!

  • Mindblaze
    • The Incredible Code Injector

    Hi Alexander,

    Thankyou for the response.

    If you head over to "Modules / Gateways" from the Pro Sites menu, then take a look at the very last one on the list. After you enable the upload quota, you can configure the limits for each level from it's settings section on the main Pro Sites settings page. You'll also be able to configure an upsell message, and out-of-space message.

    I knew this portion :slight_smile:. What I wanted to ask was that if I wanted to get how much of that space has been used 10MB, 20MB etc our of the allotted 100MB (just an example). What function or code could I use in Prosite's that can help me calculate this. It is obviously using some function to check whether user has reached the allotted quota or not, what would that function be?

  • Alexander
    • DEV MAN’s Mascot

    Ok, so here's the code/function you're looking for:

    get_site_option('blog_upload_space');

    The upload quota creates a filter that runs everytime that function is called and tests to see if it has reached the maximum allowed amount.

    Does this answer your question?

  • Mindblaze
    • The Incredible Code Injector

    Thankyou,

    This is close but not the exact thing that I was looking for. This returns the max limit "allowed" for the blog. I need the code that checks how much has been "used" uptil now. Obviously there must be check like that otherwise just stating the max limit cannot prevent people from exceeding it without a check that can calculate how much has been "used" till now.

    So I need that part of the code that checks it. Hope that makes it clear.

  • Aaron
    • CTO

    There is a core function, it used to be added to the right now widget via filter, but that filter has been disabled in later versions of WP.
    display_space_usage()

    Just putting this line in a network or mu plugin would add it back to all blogs:
    add_action( 'rightnow_end', 'display_space_usage' );

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.