Wednesday, June 8, 2022
HomeWordPress Developmentperson roles - Methods to repair the Publish Preview Button (CPT &...

person roles – Methods to repair the Publish Preview Button (CPT & map_meta_cap)


I am attempting to create a customized put up sort that may be edited by customers with a customized function (in addition to directors, editors and authors).
Althought the thought for the customers with this practice function is for them to not have the ability to create, delete or view the CPT record by way of admin. They need to solely have the ability to edit non-private CPTs assigned to them by directors, editors or authors.

Setup:

register a customized put up sort with

'capability_type' => [ 'cpt', 'cpts' ]
'capabilities'    => [ 'create_posts' => 'create_cpts' ]
'map_meta_cap'    => true

and a put up meta cpt_administrator containing the ID of the person to which the put up has been assigned;

add a customized function cpt_administrator with solely these capabilities:

'learn',
'edit_published_cpts',
'upload_files',

and add a filter for map_meta_cap to take away the aptitude edit_others_cpts from the present put up if the meta cpt_administrator corresponds to the ID of the present person.

The whole lot is working nicely apart from the Preview button (each on the traditional and and on the block editor)

On the Block Editor the “Preview” dropdown is lacking the “Preview in new tab” button.
This button seems provided that I grant edit_cpts to cpt_administrator, which I do not need to do as a way to keep away from the person to view the CPT record by way of admin.

On the Traditional Editor: the “Preview” button does not redirect correctly if left-clicked (it sends to /wp-admin/put up.php with out question parameters).
Though it really works if mousewheel-clicked (opened in a brand new tab)

I used to be contemplating to report this behaviour on Trac, however first I’d have wish to know if there was any workaround for that, though I did not discovered any filter I can hook to as a way to repair this behaviour.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments