[wp-hackers] Mapping meta caps only to attachments and unpublished posts

William Davis will.davis at gmail.com
Thu Jan 13 18:00:14 UTC 2011


I'm trying to allow users to only delete unpublished posts and  
attachments. I removed their meta cap to delete posts and am trying to  
add it back selectively with the code below, but am not having any  
luck. Any help would be much appreciated.

if ( 'delete_post' == $cap ) {
		$post = get_post( $args[0] );
		$post_type = $post->post_type;
		if( $post_type == 'attachment' ) {
			$post_type = get_post_type_object( $post->post_type );
			$caps[] = 'delete_post';
		}
}

William P. Davis
will.davis at gmail.com
207.660.5342
http://twitter.com/williampd
http://www.wpdavis.com





More information about the wp-hackers mailing list