Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Oh ok, I thought you were talking about the ‘Visibility: Private’ section that shows up on the right hand side on the ‘Write Post’ page.

    To remove the “Private: ” part from the title of the post, change the following line of code in your code above:
    $private_title_format = apply_filters('private_title_format', __('Private: %s'));

    To this:
    $private_title_format = apply_filters('private_title_format', __('%s'));

    That should do it ??

    Sagar

    To hide the Visiblity: Private part that shows up, find the following code in the same file:

    <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
    
    if ( 'private' == $post->post_status ) {
    	$post->post_password = '';
    	$visibility = 'private';
    	$visibility_trans = __('Private');
    } 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 {
    	$visibility = 'Private';
    	$visibility_trans = __('Private');
    }
    
    echo esc_html( $visibility_trans ); ?>

    And replace it with the following:

    <!-- <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
    
    if ( 'private' == $post->post_status ) {
    	$post->post_password = '';
    	$visibility = 'private';
    	$visibility_trans = __('Private');
    } 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 {
    	$visibility = 'Private';
    	$visibility_trans = __('Private');
    }
    
    echo esc_html( $visibility_trans ); ?> -->

    Again, simply commenting out the section ??

    Hope this helps ??

    Regards,
    Sagar

    Just discovered how to do this:

    For this, you need to edit the file ‘meta-boxes.php’ located in wp-admin/includes/ folder.

    Open that file in NotePad and find the following code:

    $visibility = 'public';
    $visibility_trans = __('Public');

    Now, all you need to do is change it do the following:

    $visibility = 'private';
    $visibility_trans = __('Private');

    Done.

    You can even hide the Visibility option so that users can’t change it. To do that, find the following code in the same file:

    <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
    
    <div id="post-visibility-select" class="hide-if-js">
    
    <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" />
    <?php if ($post_type == 'post'): ?>
    <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> />
    <?php endif; ?>
    <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
    
    <input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
    <?php if ($post_type == 'post'): ?>
    <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID)); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page') ?></label><br /></span>
    <?php endif; ?>
    <input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
    <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span>
    <input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
    
    <p>
     <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
     <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
    </p>
    </div>

    Replace that with the following:

    <!-- <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
    
    <div id="post-visibility-select" class="hide-if-js">
    
    <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" />
    <?php if ($post_type == 'post'): ?>
    <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> />
    <?php endif; ?>
    <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
    
    <input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
    <?php if ($post_type == 'post'): ?>
    <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID)); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page') ?></label><br /></span>
    <?php endif; ?>
    <input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
    <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span>
    <input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
    
    <p>
     <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
     <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
    </p>
    </div> -->

    Basically, just commenting out the part by using <!– and –>. A plugin for this would be awesome.

    WARNING: Commenting out the form will mean that NO ONE can make a public or password protected post. And all your pages will be Private by default without an option to change them back to public.

    The work around is that after you create a page or write a post you want to be public, just go to the ‘Edit Posts’ or ‘Edit Pages’ screen and uncheck the ‘Private Post’ / ‘Private Page’ checkbox under Quick Edit.

    Regards,
    Sagar

    I am looking for a solution to this myself.

    I’d love to learn how this can be done.

    Sagar

    Thread Starter sagar_mehta

    (@sagar_mehta)

    Thanks a lot for that code Michael. Works really well!

    For anyone who’s trying to achieve the above, put the code in your page template.

    Then, whenever any post is made by a contributor and is set to ‘Private’, only that contributor will see the post. To all others, it will be hidden.

    Thanks again!

    Regards,
    Sagar

Viewing 5 replies - 1 through 5 (of 5 total)