Allow Contributor to edit published post and filter by page id

You can use user_has_cap filter to check and grant capabilities dynamically. add_filter(‘user_has_cap’, ‘contributor_can_edit_published_posts’, 10, 4); function contributor_can_edit_published_posts($allcaps, $caps, $args, $user) { global $post; // Do we have a post? if ( ! $post ) { return $allcaps; } // Is the user a contributor? if ( ! isset( $allcaps[‘contributor’] ) || true !== $allcaps[‘contributor’] ) … Read more

How to modify Publish metabox?

I always do it with Frank Bültge’s Adminimize in Global Options, you’ll find Your Own Options in the left column you put any name for your reference in the right column you put the ID or Classes you want to hide if I’m not mistaken, you’d want to hide this #visibility.misc-pub-section,.misc-pub-section.curtime.misc-pub-section-last Here’s a reference list … Read more

publish_post action hook not working

If you did this instead… function the_fat_lady_sings() { wp_die(“this plugin is a far harder than i imageined”); } add_action(‘publish_post’,’the_fat_lady_sings’) I think you will see that it does work. The problem you are having with the echo is because WordPress processes the submission and then redirects back to form. You’ll never see the echoed string. That … Read more

Make the Status, Visibility, or Date fields opened by default in the Publish box

This jQuery code seems to work, when added via the admin_footer hook. #submitdiv = the whole Publish metabox .misc-pub-section = each UI section (except the Publish and Save sections) .hide-if-js = the fields that are hidden by default $(‘#submitdiv .misc-pub-section’) .has(“#post-status-display, #timestamp”) .find(‘.hide-if-js’) .toggle(); That will unhide the Status dropdown and the Date picker.

How to give capability (publish contributors posts) to author role?

I think that the best approach is to add the edit_other_posts capability to “author” role in plugin/theme activation and remove that capability on plugin/theme deactivation. With this method you only run the task once and you don’t need further coding. Using plugin activation/deactivation: register_activation_hook( __FILE__, ‘cyb_activation_function’ ); function cyb_activation_function() { $author = get_role( ‘author’ ); … Read more

new_to_publish fires multiple times

OK! found how to – there is 2 little information about how to attach a function to a status change but this hook does the job and does it well. function miniupdate_webnews( $new_status, $old_status, $post ) { if ( $old_status == ‘draft’ && $new_status == ‘publish’ ) { // YOUR FUNCTION HERE… } } add_action( … Read more