Restrict WordPress Media Library for a specific user role (users can only see/select own media)

add this to your functions.php or in a snippet, with this code the users with role external will only see their own uploads, any other role will see them all just has before. add_filter( ‘ajax_query_attachments_args’, ‘role_external’ ); function role_external( $query ) { $user_id = get_current_user_id(); if ( $user_id && current_user_can(‘external’) ) { $query[‘author’] = $user_id; … Read more

How can I create more upload paths, like a post corresponding to a post title folder used to store images of the same product

This probably isn’t the whole solution for you as you didn’t post any code, so I can’t incorporate what I know with anything, however, the following snippet will upload an image into a custom directory, made at the time of execution, as the attachment. I’ve commented the key lines… function upload_to_new_dir() { global $post; //This … Read more

How do I modify the “Insert Media” lightbox in the admin to only show media items from a category?

I think you can go about the filter list_terms_exclusions, but i don`t tested. example: function fb_list_terms_exclusions($args) { if ( ‘media-upload-popup’ != $where ) return $where; if ( !current_user_can(‘manage_categories’) ) $where = ” AND t.slug NOT IN (‘uncategorized’, ‘category-2’)”; // slug of categories return $where; } add_filter( ‘list_terms_exclusions’, ‘fb_list_terms_exclusions’ ); update for the comments to this … Read more

Pull images from the gallery

Use get_children() (Codex ref): $images = get_children( array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’ ) ); The first image will be $images[0]. EDIT: And by “first image”, I mean, the $ID of the first image, which you can use with any of the myriad image- and … Read more

WordPress bug with capabilities?

Activate the plugin again, reset your caps to default. I guess the problem is the plugin – not wp. Maybe it misses to add some capability. Best would be to try to take a look at the capabilites that are assigned to the different roles. How-to inspect current user data the smart way Create an … Read more

Out of Memory when Uploading an Image

This isn’t a WordPress problem. There’s no telling on a shared environment what the culprit might be. You probably don’t have access to your php.ini config, nor do we know how many websites your hosting company has jammed on your server. The very nature of a shared server is that each client shares the resources … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)