Gutenberg: Custom slug removed when Contributor submits post for review

Created on 13 Feb 2019  路  4Comments  路  Source: WordPress/gutenberg

Describe the bug
When a user with the role of Contributor submits a post for review, it erases any customization to the post slug/permalink and resets to the default version based on the post title.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new post as a Contributor
  2. Customize the slug in the permalink
  3. Save a draft
  4. Go back to the posts screen
  5. Edit the draft post again, see that the custom slug remains.
  6. Submit for review, notice that the permalink slug now is back to the default

Expected behavior
Slug should remain as the customized version

Screenshots
contrib-slug-reset

[Feature] Permalink [Type] Bug

All 4 comments

I was searching to see if this issue has been resolved after YEARS! Seems not, no one really cares about it really I guess.

This is the issue reported 4 years ago:
https://core.trac.wordpress.org/ticket/29999

3 years ago by me:
https://core.trac.wordpress.org/ticket/37262

Reported again 2 weeks ago here:
https://core.trac.wordpress.org/ticket/46486

A patch also created for it but never came with the core of the wordpress, so each time I need to patch this manually. My posts which have been created by contributors are publishing automatically after 1 year, so suddenly I see, slugs of tens of my posts have been reset. (The times that I forget to patch this after each wp update) Then I need to spend hours to rewrite those slugs!

To fix this issue, follow these steps:

1- Go to this file => /wp-admin/includes/meta-boxes.php

2- replace this

if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
}

by this

add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );

3- Go to this file => wp-admin/edit-form-advanced.php

4- replace this

if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) {

by this

if ( $post_type_object->public聽) {

5- Go to this file => wp-includes/post.php

6- Comment this section out

if ( ! $update && 'pending' === $post_status && ! current_user_can( $post_type_object->cap->publish_posts ) ) {
$post_name = '';
} elseif ( $update && 'pending' === $post_status && ! current_user_can( 'publish_post', $post_ID ) ) {
$post_name = '';
}

Just noting that this indeed seems like a duplicate of https://core.trac.wordpress.org/ticket/29999, as mentioned above.

@SergeyBiryukov, please check carefully again, the first step in my comment is in another file than ticket you mentioned

Was this page helpful?
0 / 5 - 0 ratings