I am trying to enable slug Metabox for contributors. Find a code to remove slug Metabox try to change it in way to work around my problem but nothing happens.

function add_contributor_post_meta_box() {
    global $post;
    if ( current_user_can( 'edit_post', $post->ID )) {
    add_meta_box('slugdiv', 'post', 'normal');
add_action('admin_menu', 'add_contributor_post_meta_box');

Anyone can help to solve this problem?
My main problem coming from, when a contributor sends a post and enters the title and permalink after sending it for review the permalink automatically changes to the main title, I don't want this to happen, also need to know how to fix this problem any help?


I approached by doing the opposite with using remove_meta_box() for the Slug metabox if the user is not an administrator or contributor:

add_action( 'admin_menu', 'wpse_237291_remove_slug_metabox' );
function wpse_237291_remove_slug_metabox() {
    $user = wp_get_current_user();
    $allowed_roles = array( 'administrator', 'contributor' );

    if ( !array_intersect( $allowed_roles, $user -> roles ) ) {
        remove_meta_box( 'slugdiv', 'post', 'normal' );
|improve this answer|||||
  • Woow, Couldn't believe but it did work. Thank you so much. I have added the following code for all roles that is correct right? $allowed_roles = array( 'administrator', 'author','editor' ,'contributor' ); – MMTDesigner Aug 29 '16 at 4:44
  • It did show the slug meta box but still after sending the post for review as an contributor wordpress still changing the slug to the title. I am writing my title in Persian and want to write the permalink in English. any other suggestions? – MMTDesigner Aug 29 '16 at 4:50
  • When the editor changes the title to another thing. If the contributor send any other changes for review the permalink would be changed again to the original title. Is it normal? or a problem coming from Wordpress? or perhaps my theme having some problems? – MMTDesigner Aug 29 '16 at 4:55
  • @MMTdesigner What you're asking for, convert Persian title into an Englush permalink, is a completely new question. In regards to your original question above and based on your comments, I'd say this one is resolved. You can click the green checkmark on this answer then open up another question. – Ethan Jinks O'Sullivan Aug 29 '16 at 11:46
  • After sending the article for review the slug box disappears how can I avoid that problem? – MMTDesigner Sep 1 '16 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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