• Resolved Antonio Gallo

    (@antoniogallo)


    For some reason the posts got duplicated when a non-admin users try to publish a custom post type. The duplciated posts has the “revisionize” label while the other not. If i try to update the post as admin then the two posts are automatically merged.

    I am missing some wordpress’s permission to add to the role of non admin users to make it work correctly?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author jamiechong

    (@jamiechong)

    Does your custom post type definition have any settings for
    capability_type or capabilities ?

    What role is your non-admin user? Is it one of the stock WP roles or have you created a new one? If it’s a new one, which capabilities have you given it?

    Thread Starter Antonio Gallo

    (@antoniogallo)

    Its a custom role and i gaved it almost all the stuff to manage the “farm” type:
    'capability_type' => 'post',

    However i’ve checked the code meanwhile and as mentioned into another post
    it seems that this has fixed the problem:

    add_filter('revisionize_user_can_revisionize', function() {
    	return current_user_can('edit_farms') || current_user_can('edit_farm');
    });
    
    add_filter('revisionize_user_can_publish_revision', function() {
    	return current_user_can('publish_farms');
    });

    is this the correct things to do?

    Plugin Author jamiechong

    (@jamiechong)

    'capability_type' => 'post' is the default, so you don’t even need to explicitly define that.

    I think you only need to add those filters if your user doesn’t have the *_post capabilities. Is that the case?

    Thread Starter Antonio Gallo

    (@antoniogallo)

    Yes they don’t have edit_post they only have edit_farms

    Plugin Author jamiechong

    (@jamiechong)

    Using those 2 filters should work to solve your problem. But the way you’ve written them, _only_ users with edit_farms caps will be able to revisionize. You’re not including the default value. You may want to consider something like this, but of course every situation is different.

    
    add_filter('revisionize_user_can_revisionize', function($userCan) {
    	return $userCan || current_user_can('edit_farms');
    });
    
    add_filter('revisionize_user_can_publish_revision', function($userCan) {
    	return $userCan || current_user_can('publish_farms');
    });
    

    You can always look at the source to see where these filters are being used:
    https://github.com/jamiechong/revisionize/blob/master/revisionize.php#L423-L429

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Duplicate post on publish’ is closed to new replies.