Hide comments from admin comments.php that user can’t edit or manage

I found another piece of code on the internet which I have modified to work. add_filter(‘the_comments’, ‘edit_comments_filter_comments’); function edit_comments_filter_comments($comments){ global $pagenow; $currentuserid = get_current_user_id(); if($pagenow == ‘edit-comments.php’ && !current_user_can(‘edit_others_posts’)){ foreach($comments as $i => $comment){ $the_post = get_post($comment->comment_post_ID); if($comment->user_id != $currentuserid && $the_post->post_author != $currentuserid) unset($comments[$i]); } } return $comments; } As I understand it, this … Read more

Non-super-admin users cannot access CPT even though I have explicitly added the capabilities to the user role

Here’s how I’d handle it (mostly you’re right, and the tweak in your answer to use init gets you closer, but — as you’ve discovered — doing a bunch of switch_to_blog() / restore_current_blog() calls on every single page load is costly). function add_opportunities_capability_to_admins() { // Set up the needed capabilities. $capabilities = array( ‘edit_opportunity’, ‘read_opportunity’, … Read more

How to correctly override a filter?

Try: function allow_daniel_edit( $caps = array(), $cap = ”, $user_id = 0, $args = array() ) { if ($user_id == 59) { return array( ‘bp_moderate’ ); // or some other permission or additional permissions } return $caps; } add_filter( ‘map_meta_cap’, ‘allow_daniel_edit’, 999, 4 );

Make plugin admin page visible to other roles

When the submenu is registered: add_submenu_page( ‘woocommerce’, __( ‘Betalingsmetoder’, ‘wcrb’ ), __( ‘Betalingsmetoder’, ‘wcrb’ ), ‘manage_options’, ‘payment-gateway-report’, ‘wcrb_report_page_callback’ ); You’ve specified that you only want it to be shown to users with the capability manage_options. So only administrators have that capability, so only administrators can see that page. It’s documented in the official WP docs … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)