Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well...as far as showing only certain media to certain users is concerned...</p> <p>We can check where they're viewing their media at, if you're simply talking about the default Media Library within the WP-Admin interface, then we can check the URL to see if they're on a Media Library page.</p> <p>We'll (likely) be placing this code in the functions.php file of our theme, or in our plugin, respective to your design.</p> <pre><code>//we need access to the $wp_query; global $wp_query; //now we build our function, we need to pass $wp_query into it function manage_user_media($wp_query){ //we check the location of the window if(strpos($_SERVER['REQUEST_URI'], '/wp-admin/upload.php') !== false || strops($_SERVER['REQUEST_URI'], '/wp-admin/media-upload.php') !== false): //check if the logged in user has a capability of say...a level 5 user if(!current_user_can('level_5')): //this user does not have the capabilities of a level 5 user. //hijack the 'author' query var, so we can set it to the ID of our user $wp_query-&gt;set('author', get_current_user_id()); endif; endif; } </code></pre> <p>If <a href="http://codex.wordpress.org/User_Levels" rel="nofollow">Wordpress User Levels are confusing to you, have a look at the Codex for comparison</a>.</p> <p>This means, that anyone over a level 5 user can see <strong>[<em>ALL</em>]</strong> media elements, where as anyone below a level 5 user, will only be able to view only <strong>[<em>HIS OR HER</em>]</strong> media elements.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload