Word Cracker의 잡다한 정보 모음

How to hide the ‘Edit’ menu for non-administrators in bbPress

Comments 3

You may want to restrict editing bbPress posts by users who are not administrators. For this, the following function should work:

function change_admin_links ($r) {
if ( empty( $r['links'] ) && (current_user_can('editor') || current_user_can('administrator')) ) {
$r['links'] = apply_filters( 'rw_reply_admin_links', array(
'edit'  => bbp_get_reply_edit_link ( $r ),
'move'  => bbp_get_reply_move_link ( $r ),
'split' => bbp_get_topic_split_link( $r ),
'trash' => bbp_get_reply_trash_link( $r ),
'spam'  => bbp_get_reply_spam_link ( $r ),
'reply' => bbp_get_reply_to_link   ( $r )
), $r['id'] );
} else

$r['links'] = apply_filters( 'rw_reply_admin_links', array(
'reply' => bbp_get_reply_to_link   ( $r )
), $r['id'] );
return $r['links'] ;
add_filter ('bbp_reply_admin_links', 'change_admin_links' ) ;

Please add the above code to your WordPress theme’s functions file (functions.php under your theme’s folder). Of course, if you uses a child theme, please add it to the functions file of your child theme.

Now users who do not have Administrator or Editor privileges cannot edit their posts. This will prevent users from modifying the posts by purpose.

I tested it and it worked well. If it would not work, you may edit the file “template.php” under “\wp-content\plugins\bbpress\includes\replies\”. (However, as you know, it’s not desirable to edit the source files of plugins whenever possible.)

Related Posts


이 글의 링크 복사