Viewing 1 replies (of 1 total)
  • Plugin Author 3pointross

    (@3pointross)

    Hi Christoph,

    This thread here has some good ideas on how to make posts private by default.

    The code I’d use is at the bottom, this could go into the bottom of your functions.php file.

    function default_post_visibility(){
    	global $post;
    
    	if ( 'publish' == $post->post_status ) {
    		$visibility = 'public';
    		$visibility_trans = __('Public');
    	} elseif ( !empty( $post->post_password ) ) {
    		$visibility = 'password';
    		$visibility_trans = __('Password protected');
    	} elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) {
    		$visibility = 'public';
    		$visibility_trans = __('Public, Sticky');
    	} else {
    		$post->post_password = '';
    		$visibility = 'private';
    		$visibility_trans = __('Private');
    	} ?>
    
    	<script type="text/javascript">
    		(function($){
    			try {
    				$('#post-visibility-display').text('<?php echo $visibility_trans; ?>');
    				$('#hidden-post-visibility').val('<?php echo $visibility; ?>');
    				$('#visibility-radio-<?php echo $visibility; ?>').attr('checked', true);
    			} catch(err){}
    		}) (jQuery);
    	</script>
    	<?php
    }
    add_action( 'post_submitbox_misc_actions' , 'default_post_visibility' );
Viewing 1 replies (of 1 total)
  • The topic ‘Set projects to private by default’ is closed to new replies.