-2

I need to assign to an user role the capabilities for the user to only edit his own uploaded files (instead of edit all files like happen for the capability upload_files). Considering that there is not a native capability for that, how can I achieve the desired result?

hhh
  • 394
  • 2
  • 15

1 Answers1

0

I believe you could:

  1. Define your role and add a custom capability (eg. edit_own_files) via Roles and Capabilities guidelines
  2. Use the user_has_cap filter to modify whether the user has the "upload_files" capability - depending on which file they are trying to edit, and if they are the author.

That approach depends on the "upload_files" check passing what you need via the "$args" parameter.

So, you'll have to do some testing - and if it doesn't do what you need, you might need to hunt for a different filter.

Chris
  • 359
  • 1
  • 8