Skip Navigation

[Resolved] “#No_privilege” error when trying to edit images

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

Problem: When Users in 4 specific custom roles try to edit images, the edit links are incorrect. They show the URL hash "#No_privilege".

Solution: The root issue should have been resolved with Access 2.7.2: https://toolset.com/errata/if-toolset-access-and-wpml-are-active-together-you-cannot-edit-any-posts-controlled-by-toolset-access/

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

Tagged: 

This topic contains 15 replies, has 2 voices.

Last updated by Christian Cox 5 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#617977

Hi Christian,

Per your request, opening a separate ticket for this issue. Please note, I marked hidden link as the domain I need help with, but we're doing all the troubleshooting on the staging site, which you have access to (same credentials I gave you earlier).

Issue: can't edit images in the media library. Getting the #no_privilege link there as a developer (highest) level user.

Also, with ONLY Toolset (full suite) and WPML (full suite) on, I am still unable to get to edit images in the media library. When WPML plugins are deactivated, I am able to edit images. So your plugin suites seem to have a compatibility issue between themselves. BUT - When WPML is on, and I deactivate Access only, I can edit the images.

THanks,
Nadav

#618299

I can't see any obvious configuration problems, and I can replicate this on your staging site with only Toolset and WPML plugins and Twenty Seventeen active. However, I cannot replicate the same problem on my own local environment. Since site duplication plugins aren't allowed on Flywheel, I think the next step if to create a backup of your database so we can attempt to replicate the problem locally. I will activate private reply fields here so you can provide download link to a SQL backup file.

More information from Flywheel about accessing the DB:
https://getflywheel.com/wordpress-support/can-get-access-database/

#618389

Hi Christian,

Here's a download link to the SQL of the (live) site:
hidden link

And here's a link to the SQL of the staging site:
hidden link

Nadav

#618477

Thank you, I have downloaded those backups and replicated the issue locally with the staging DB active. I updated all the plugins, updated WordPress, and activated a default theme. The problem remains. So I need to escalate this to my 2nd tier support team for further investigation. I will update you as soon as possible. In the meantime, a developer can edit any media item by accessing its URL directly rather than using the Edit link:
hidden link

#619499

Thanks, please keep me posted. I understand I can edit via a post.php?post=54046&action=edit type of link, but I can't instruct the staff to work this way, unfortunately.

#619711

I have an update from my 2nd tier support team. Please apply the following patch in your theme's functions.php file:

function access_edit_media_post_link_($link, $post_id, $lang, $trid){
    global $wpcf_access,$current_user;
    if(!isset($current_user))return $link;
    if ( !in_array( 'developer', (array) $current_user->roles ) ) return $link;
    $wpcf_access->language_permissions['attachment']=array(
        'en'=>array(
            0=>'edit_any',1=>'edit_own'
        ),
        'he'=>array(
            0=>'edit_any',1=>'edit_own'
        )
    );
    return $link;
}
add_filter('wpml_link_to_translation',    'access_edit_media_post_link_', 10, 4);

In my local tests, this patch fixes Media Library links in wp-admin for Developer Users. Please let me know if this does not resolve the problem for you.

#619714

It doesn't work. I added the function to functions.php on staging, take a look.

#619783

I see in staging, in the list View only the first item in each page of results is editable. I don't see that in my local environment, so something else must be going on. Can you provide me with link to download a copy of your parent and child themes?

#619786

Give me your email address and I'll make you a collaborator on both the live and staging sites on the Flywheel dashboard. This way, you'll have full access to all the files.

#619854

I invited you to collaborate on AICF. You should have received an email with all the details.
Once you're in, here's how to get to the FTP:
hidden link

Please notice that browsing the FTP, there are two main folders: aicf and aicf_staging, so keep that in mind.

Let me know if you run into any issues!

Nadav

#620149

Thanks, I received the collaboration invite and I was able to download the parent and child themes by SFTP. To rule out a conflict in the child theme, I created my own child theme that includes only this filter code in the functions.php file. I am still able to replicate the issue where only the first image in the list of results is editable, so I am asking my 2nd tier team to take another look at their proposed solution with the Newspaper parent theme active. I will update you as soon as I have more information to share.

#622640

Okay my 2nd tier team provided a code update. I uploaded this change to the Newspaper child theme's functions.php file in staging:

function my_edit_post_link_($link, $post_id, $lang, $trid){
    global $wpcf_access,$current_user;
    if(!isset($current_user))return $link;
    if ( !in_array( 'developer', (array) $current_user->roles ) ) return $link;
    $wpcf_access->language_permissions['attachment']=Array('en' => Array('publish' => Array('roles' => Array(0 => 'developer')),'delete_any' => Array('roles' => Array(0 => 'developer')),'edit_any' => Array('roles' => Array(0 => 'developer')),'delete_own' => Array('roles' => Array(0 => 'developer')),'edit_own' => Array('roles' => Array(0 => 'developer')),'read_private' => Array('roles' => Array(0 => 'developer')),'read' => Array('roles' => Array(0 => 'developer'))),'he' => Array('publish' => Array('roles' => Array(0 => 'developer')),'delete_any' => Array('roles' => Array(0 => 'developer')),'edit_any' => Array('roles' => Array(0 => 'developer')),'delete_own' => Array('roles' => Array(0 => 'developer')),'edit_own' => Array('roles' => Array(0 => 'developer')),'read_private' => Array('roles' => Array(0 => 'developer')),'read' => Array('roles' => Array(0 => 'developer'))));
    return $link;
}
add_filter('wpml_link_to_translation',		'my_edit_post_link_', 10, 4);

Now when I'm logged in as a Developer, I see the correct edit links for all Media Library items in English and Hebrew. Can you confirm?

#622774

It works, but for developer only. Senior Staff, Staff, and Senior Staff Israel still get #no_privilege.

#623005

Okay thanks, I will ask for an update that should work for all 4 roles.

#623124

Okay here's an update that works for Developers, Staff, Senior Staff, and Senior Staff Israel:

/* #NO_PRIVILEGE FIX */

function ts_edit_media_post_link_($link, $post_id, $lang, $trid){
    global $wpcf_access,$current_user;
    if(!isset($current_user))return $link;
    $allowed_roles=array('developer','senior_staff','senior_staff_israel','staff');
    $current_user_roles=(array) $current_user->roles ;
    if ( array_intersect($allowed_roles, $current_user_roles)==0  ) return $link;
    $wpcf_access->language_permissions['attachment']=Array('en' => Array('publish' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'delete_any' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'edit_any' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'delete_own' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'edit_own' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'read_private' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'read' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel'))),'he' => Array('publish' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'delete_any' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'edit_any' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'delete_own' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'edit_own' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'read_private' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel')),'read' => Array('roles' => Array(0 => 'developer', 1=> 'staff', 2=>'senior_staff', 3=>'senior_staff_israel'))));
    return $link;
}
add_filter('wpml_link_to_translation',      'ts_edit_media_post_link_', 10, 4);
/* END */
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.