Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have this in my functions.php

function remove_quick_edit( $actions ) {
unset($actions['inline hide-if-no-js']);
return $actions;
}
add_filter('post_row_actions','remove_quick_edit',10,1);

to remove the quick edit link in the backend when scrolling the list of published posts.

It works like a charm but it disable it even for the admin role. Is it possible to keep it showing only for the admin while still diabling for the rest? Thanks!

SOLVED thanks to jfacemyer! This is the full code to add in functions.php

function remove_quick_edit( $actions ) {
unset($actions['inline hide-if-no-js']);
return $actions;
}
if ( current_user_can('manage_options') ) {
} else {
add_filter('post_row_actions','remove_quick_edit',10,1);
}
share|improve this question
    
I believe the User Role Editor plugin will let you do this. Feel free to punch me in the head if I'm wrong. –  Jared Steffen Mar 19 '13 at 18:24
    
The user role plugin has made my site instable so I needed to disable it and I've added all the small pieces of code I needed in my functions.php making them available in case I want to replicate this project in the future. Unfortunately I'm missing the quick edit removal only for non admins... –  user27309 Mar 20 '13 at 11:13

1 Answer 1

up vote 3 down vote accepted

Use current_user_can to wrap the add_filter call:

if ( current_user_can('manage_options') ) {
} else {
    add_filter('post_row_actions','remove_quick_edit',10,1);
}

manage_options is an Admin capability. If the current user can do it, he's an admin (on a vanilla WP installation).

See:

http://codex.wordpress.org/Roles_and_Capabilities

and

http://codex.wordpress.org/Function_Reference/current_user_can

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.