Skip Navigation

[Resolved] Need to give subscriber role the ability to edit images and their metadata

This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1323795

Hi,
I have post forms where users with subscriber role can upload images.
In the post form edit-page I have checked "use wordpress Library manager for images...".
And logged in subscribers can now only see their own uploaded images, when opening Media Library. And thats fine.

When uploading new images, subscriber can add metadata to the image files.

However I would like to give the ability to let logged in subscribers to edit their own ALREADY uploaded image files including metadata (title, description etc).
On the page https://toolset.com/documentation/user-guides/using-the-native-wordpress-media-manager-in-front-end-forms/
you say that it is possible with Toolset Access to
"Giving users in specific roles permissions not granted by default. This includes the ability to edit images and their metadata."

And you also on same page show a table with default permissions for using the site’s existing media files.
But I can not find out where/how to edit theses settings. I can not find a table that looks like the permissions settings you show on the help page.

Where do I edit the permissions so that subscribers can Edit own Metadata and Edit own Images?

Best regards,
Poul p
Denmark

#1323941

Hello you must do these two things:
1. Go to Toolset > Access Control > Forms tab, and find the Post Forms Frontend Access panel. In this panel, scroll to find the permission "Edit Own" posts using the Edit Post Form. Turn on this capability for Subscribers, as shown in the attached screenshot. This will give the User the ability to replace an image in a Form and select their own images from the Media Library.

2. Go to Toolset > Access Control > Post types tab, and open the Media post type. This post type must be managed by Access, and you must give Subscribers the permission to "Edit Own" Media posts.

Now your Subscribers can modify their media posts in the Media Library when they add an image to the Form. Let me know if you have trouble setting this up.

#1324079
screen.jpg

Hi,
I already knew about your suggested solutions. And the first thing I already have made in settings.
But if I also do the second thing - manage post type Media with Access - then a logged in user will see ALL uploaded images (and not only own uploaded images), when go to the address: /wp-admin/upload.php.
Furthermore in my site I have disabled access to the dashboard and toolbar for my users (subscribers). By setting Media post type to be managed by Access then a logged in user that goes to /wp-admin/upload.php will see the normal dashboard/toolbar and as mentioned ALL uploaded images from all users in Media library.

I dont know if the problem arises from the fact that in Access I can NOT only give subscribers permission to "Edit own". When I check the box also the "Read" box is automatically checked. But dont know if that why a subscriber can see ALL images (not only own images). See screenshot.

My question was if it is possible - when a user go in to Media Library from a post form, by using the buttom "replace image"- (or throug another URL than /wp-admin/upload.php directly) to allow the user to edit others of his already uploaded images.

As it is now there is no option for editing existing images, if a user access Media Library through a post form.

I dont want ny users to be able to access /wp-admin/upload.php directly.

Best regards,
Poul

#1324505

I can offer a couple of custom code snippets to restrict wp-admin access and the top admin menu bar from Subscribers:

add_action( 'init', 'custom_dashboard_access_handler');
function custom_dashboard_access_handler() {

   // Check if the current page is an admin page
   // && and ensure that this is not an ajax call
   if ( is_admin() && !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ){
      
      //Get all capabilities of the current user
      $user = get_userdata( get_current_user_id() );
      $caps = ( is_object( $user) ) ? array_keys($user->allcaps) : array();

      //All capabilities/roles listed here are not able to see the dashboard
      $block_access_to = array('subscriber');
      
      if(array_intersect($block_access_to, $caps)) {
		  
         wp_redirect( home_url() );
         exit;
      }
   }
}

add_action('after_setup_theme', 'remove_admin_bar');
 
function remove_admin_bar() {
if (!is_admin()) {
  //Get all capabilities of the current user
      $user = get_userdata( get_current_user_id() );
      $caps = ( is_object( $user) ) ? array_keys($user->allcaps) : array();

      //All capabilities/roles listed here are not able to see the dashboard
      $block_access_to = array('subscriber');
      
      if(array_intersect($block_access_to, $caps)) {
		  
         show_admin_bar(false);
      }
}
}

You can add that code to a child theme's functions.php file to remove the ability to access /wp-admin/upload.php directly, as well as the ability to see the top admin bar.

As far as editing other previously uploaded image metadata, it is possible in this setup, though the workflow is somewhat clunky. Your Subscribers would have to use the Edit Post Form and click "Replace Image" to open the Media Library. At this point, they can see any image they have uploaded. Let's assume Image 1 is already selected. If the Subscriber wants to modify the metadata for Image 2, they can choose Image 2 and change the metadata. Then insert Image 2 in the Form. At that point, they would have to click "Replace image" again to choose Image 1 again, but the metadata for Image 2 has already been saved.

I just ran a quick test to confirm this is working as expected. Here's the sandbox site I created:
hidden link
Here is a login for a Subscriber:
ChristianCox
mSnhr)EYAb8oLG@$^x(%30Cv

Then you can go here to create a "Book":
hidden link

After creating the book you will be automatically redirected to the single Book page. You'll see a link to edit your book. Click that link to display the Edit Post Form. If you click "Replace Image" you'll be able to see other images this User has already uploaded in the Media Library (but not other Users' images). You can follow the steps I outlined before to edit the metadata for any previously uploaded images.

You can also try to go to the wp-admin area or /wp-admin/upload.php directly.

Please let me know if I've misunderstood the problem and I'll take another shot.

#1324587

Hi,
you have understand the problem correctly, however I think you know your self that the suggested solution is not something a normal website can offer to its users.
So I assume its not possible with toolset to allow users to edit their own images? right? (its only possible to replace or delete).

If you dont have better solutions, then I think we should close this support ticket now.

best,
Poul

#1324619

If the User uploaded an image in post A, then I wouldn't expect them to be able to edit that image (or its metadata) by editing post B in a Form. Editing other previously uploaded images this way seems unusual as well, and I don't understand why you would do it this way. The user should edit the image metadata from a Form that edits the original post where the image was added, not a Form that edits some arbitrary other post. Then the extra workflow to replace the original image isn't necessary. I think that is a better solution. In either workflow, the User must click the button that says "Replace" or delete the image and add a new image to open the Media Library. I don't see another way around that.

#1324835

My issue is resolved now. Thank you!