upload anh trong wordpress
In my previous article more guidance Export your movie in the user profile in wordpress, this article I wrote that article, if you have not you can see here.
In this article I will apply Export your movie in the previous article to limit upload images for the user in wordpress, for example, the default for each user upload 20Mb, if more will appear to inform the user must contact the admin, if admin is the admin will contact the user to change the value of quota for the user, this is the code I have done in recent times, after a successful study, which now sits post here for people to see.
You copy the code below and paste into the functions.php file offline.
I will explain briefly the meaning of the code above for your reference or change in its sole discretion.
First as a function “admin_js”, look at the you know what it does, right, used to upgrade message appears when the user account upload quota allows. This function will be executed using the command line “add_action (‘admin_head’, ‘admin_js’);”, wordpress like to make a script is not as easy as outside sites where you have to call a new action.
Ham “checkMidiaSizeByUser” used to check the size of the user’s media, the first function will take on two values: the id of the user and the capacity limit, then use the loop to calculate the amount of media that carry id user is the user logon. if a larger capacity is limited capacity at the same time the user is not admin, the command will perform two “add_action (‘admin_head’, ‘removemediabuttons’);” and the “add_action (‘admin_head’, ‘admin_js’) ; “solution to remove the upload button in the wp admin and currently informed replaced by the upload button while composing this article. And last solution is to reset the query so that it returns to normal, if not the implementation of off-site loop will fail.
Said their facilities are always available for you always, command “wp_reset_query ();” used a lot, I often use it to fix some bugs in the wordpress plugins that are most as: latest posts related post. The plugin writes the loop but does not reset it, so when you use a loop in the web page, all your posts it will last in the plugin.
<?php global $current_user; get_currentuserinfo(); if($current_user->dungluong != '') $dungluong = $current_user->dungluong; else $dungluong = 20; $limit = 20*1024*1024; checkMidiaSizeByUser($current_user->ID, $limit); ?>
This function is related to my previous post, you see the light, for that space. in this code snippet, I consider two cases, one is part of that space will get the default is 20Mb, if the value of which will take the value that night workers in 1024 and 1024, ie in the user you just fill the space under the unit is Mb.
You do not? This article seems to be slightly higher, it is also less common application, personal web page if you do, you do not need to do anything.
in the above code is one I have not done, it calculated the amount of new writing only, but in the process of uploading media, it does not stop when you are uploading, for example, your storage space is 1Mb, but you are uploading another 5Mb, it is still the normal upload, it does not stop. When you write a new post again, it does not let you upload, should rather stop now reached capacity limits. I also write code to play alone, should not be developed further, if one code and then the comment section below for you to see offline.
If you copy my post, please remember to link the source to me.
This article is useful for you, press like on my help, encourage writing.