Skip Navigation

[Resolved] Restrict Media Library Access

This thread is resolved. Here is a description of the problem and solution.

Problem:

The button "Add media" of Toolset post form does not respect the setting of "Use any Media Library file when adding files to front-end Post Forms".

Solution:

It is a known issue of Toolset Forms plugin, currently, you can try to add below codes into your theme file functions.php:

add_filter( 'ajax_query_attachments_args', 'wpb_show_current_user_attachments' );
function wpb_show_current_user_attachments( $query ) {
    $user_id = get_current_user_id();
    if ( $user_id && !current_user_can('activate_plugins') && !current_user_can('edit_others_posts
    ') ) {
        $query['author'] = $user_id;
    }
    return $query;
}

Relevant Documentation:

100% of people find this useful.

This support ticket is created 4 years, 6 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 22 replies, has 3 voices.

Last updated by michaelO-8 4 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1762075

There is a misunderstanding, it requires the current post author to edit the post and attach files, for example, the URL you mentioned above:
hidden link
This post's author is "XXXXX", you will need to login as user XXXXX(ID 3863)

Then test again.

#1762455

Hi Luo,

Yes, I did log in as that user and still get that error message. I also get it when trying to edit a booth created by a test user wsue. Can you not replicate this on the duplicator package?

Also, if possible, please remove the name and information for that user from the post as I would like to keep their information confidential. Thank you!

#1763081
upload-image.JPG

I have tried it with your database dump file in my localhost(Fresh WP installation + the latest version of Toolset plugins), it works fine after I login as user post author I mentioned above, I can upload the image files in the editing post form without any problem.
see my screenshot upload-image.JPG

So the problem is abnormal, please do the normal debug steps again:
https://toolset.com/forums/topic/restrict-media-library-access/#post-1735351

If the problem still persists, please provide the new database dump file again. private message enabled again.

And I have edited my post to remove the author's name

#1764309

Hi,

Thank you for sharing these details.

Luo is on a holiday today and will be following up on this, when he comes back tomorrow.

Thank you for your patience.

regards,
Waqar

#1764771

Thanks for the details, I am downloading the files, will update here if find anything

#1765853

I can see the problem with the new database dump file, need to to compare the settings between new database dump file and old one, will update here if there is any finds

#1765867

Please try this:
Dashboard-> Toolset-> Access control-> Post types
find and click post type "Booths", enable option "Publish" option for user role "Wayne State Employer", and test again, it works fine with your new database dump file in my localhost.

Since the edit post form "Edit Booth Post (ID: 3111)", it is for editing "Booth" post, you will need to grant the "Publish" privilege to user role "Wayne State Employer"

#1768537

Thank you very much for your persistence, I really appreciate it!! This solved my issue.