1

I want to make it so that, when a post's (not page) status is published, non-admins will not be able to change the URL (using the interface shown in the image). Maybe it's greyed out or just not present? What I had been doing was just hiding the permalink editor for posts:

.wp-admin.post-type-post.edit-post-post-url__dialog .components-base-control {
    display: none;
}

But this disallows URL editing before publishing. Is there a way to do this wp.data?

permalink editor

1 Answer 1

0

You could do something like the following, this should go in your Child Theme's functions.php or if not using a Child Theme then add to a custom plugin:

    function hide_permalink_metabox( $is_post_edit_page ) {
    if ( !current_user_can('update_core') ) {  // allows Admins to edit the permalink
    echo '<style>
    div#edit-slug-box {display:none!important;}
    </style>';
}

You may need to double-check the actual ID of the permalink DIV, it might be different from mine depending on what version of WP you're using and if you're using the Blocks Editor (I don't, I use the Classic Editor).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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