Thanks for your interesting question and for searching through the documentation to find an answer. There is no one parameter that will accomplish your goal, but it can be done with a bit of effort.
User roles are derived from capabilities, and they are not explicitly associated in the database with the items uploaded by each user. Using MLA’s mapping rules you can populate a custom field with the role value and then use the custom field to compose the query you need. The current MLA version requires some help to access the role value; this is provided by one of the Example Plugins included with MLA. There are three steps required to complete your application: 1) install the example plugin, 2) create the custom field and 3) compose the [mla_gallery]
query.
First, navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. You will see a submenu that lists all the example plugins and gives you a “one-click” action for installing them. Enter “substitution” in the search text box and click “Search Plugins” to filter the table.
You are looking for “MLA Substitution Parameter Hooks Example” plugin. Find that plugin and hover over the title in the left-most column. Click the “Install” rollover action, then go to the Plugins/Installed Plugins submenu and activate it as you would any other WordPress plugin.
Let me know if your site uses PHP version 7.x; there is a small incompatibility in the example plugin with those PHP versions. If this affects you I can give you a Development Version that corrects the problem.
Second, create a mapping rule for your new field:
- Navigate to the Settings/Media Library Assistant “Custom Fields” tab.
- Make sure the “Enable custom field mapping when adding new media” box is checked. If not, check the box, scroll down to the bottom of the page and click “Save Changes”.
- Scroll down to the “Add a new Field and Mapping Rule” area.
- In the first text box, give your field a name, e.g., “Author Role”.
- From the Data Source dropdown list, select “- Template (see below) -”.
- In the Meta/Template text box below the Data Source dropdown, enter “[+author:roles+]”.
- In the “Existing Text” dropdown list, select “Replace”.
- In the “Format” dropdown list, select “Native”.
- Click the “MLA Column” check box if you want to make the field available as a sortable column in the Media/Assistant submenu table.
- In the “Option:” dropdown list, select “Single”.
- Click the “Delete NULL Values” checkbox.
- Click the “Add Field and Map All Attachments” button to save your work and create the “Author Role” value for the items already in your Media Library.
Third, compose your query. Navigate to the post/page where you want the gallery display and add your shortcode to the content. Here are two examples to get you started. I have used the “enclosing shortcode” syntax to make the parameters easier to see and to avoid problems WordPress has in parsing complicated parameters like the meta_query
:
[mla_gallery]
post_parent=current
meta_key="Author Role"
meta_value="contributor"
[/mla_gallery]
The first example above will display a gallery of items attached to the post and uploaded by a “contributor”. The second example below will display attached items uploaded by users with any other role:
[mla_gallery]
post_parent=current
meta_query="
array(
array(
'key' => 'Author Role',
'value' => 'contributor',
'compare' => '!='
)
)"
[/mla_gallery]
The meta_query
syntax is complicated, but allows powerful queries not supported by the simpler form in the first example.
I hope that gets you started on a solution for the feature you’re seeking. I am marking this topic resolved, but please update it if you have any problems or further questions regarding the above suggestions. Thanks for an interesting question and for your interest in the plugin.