[wp-trac] [WordPress Trac] #35800: Preview button for CPT not working for user with limited Capabilities

WordPress Trac noreply at wordpress.org
Sun Jul 2 04:20:31 UTC 2017


#35800: Preview button for CPT not working for user with limited Capabilities
--------------------------------------------+------------------------------
 Reporter:  Webbverkstaden                  |       Owner:
     Type:  defect (bug)                    |      Status:  new
 Priority:  normal                          |   Milestone:  Awaiting Review
Component:  Posts, Post Types               |     Version:  4.4.1
 Severity:  normal                          |  Resolution:
 Keywords:  dev-feedback reporter-feedback  |     Focuses:  administration
--------------------------------------------+------------------------------
Changes (by westonruter):

 * keywords:  dev-feedback => dev-feedback reporter-feedback


Comment:

 @DrewAPicture Actually, the Customize Posts plugin actually doesn't use
 the preview nonce since the data is part of the customizer changeset, and
 so the UUID is used instead.

 @Webbverkstaden You'll want to look at the [https://github.com/WordPress
 /wordpress-develop/blob/4.8.0/src/wp-includes/revision.php#L508-L554
 _set_preview() and _show_post_preview()] functions.

 But before that, you'll want to look at [https://github.com/WordPress
 /wordpress-develop/blob/4.8.0/src/wp-includes/class-wp-query.php#L2938
 this line] in `WP_Query`:

 {{{#!php
 <?php
 if ( $this->is_preview && $this->posts && current_user_can( $edit_cap,
 $this->posts[0]->ID ) ) {
 }}}

 It could be an issue with mapping the meta caps to the primitive caps in
 your CPT. It's looking at the `edit_post` meta cap (here stored in the
 `$edit_cap` variable).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35800#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list