/*Reverse sticky header*/
  1. Home
  2. Knowledge Base
  3. Customizations
  4. CSS
  5. How to Remove “Public” Visibility from the “Who Can See Your Post ” List

How to Remove “Public” Visibility from the “Who Can See Your Post ” List

To remove the “Public” option, we need to override the template and add some custom code. Here’s how to do it:

Key Steps:

  1. Handle Existing Public Posts
    If you’re removing the “Public” option, you must handle activities that were previously posted publicly. Ensure these posts have an appropriate visibility setting applied.
  2. Set a Default Privacy Option
    When disabling the “Public” (or any other) privacy option, it’s crucial to set a default privacy level. While BuddyBoss hardcodes the “Public” option in scripts, and there’s no filter to override this by default, we can use a custom code trick to achieve this via an AJAX request.
  3. Hide “Public” Visibility from Activity Popup Box and Set “Logged In Users” as Default ( Or you can make any default but you need to adjust the custom code accordingly)

How to Override the Template:

  1. The JS template for the activity post privacy options can be found in the following path within the BuddyBoss platform:
    buddyboss-platform/bp-templates/bp-nouveau/buddypress/common/js-templates/activity/parts/bp-activity-post-case-privacy.php
  2. To override this template, copy the file to your child theme with this path:
    buddyboss-theme-child/buddypress/common/js-templates/activity/parts/bp-activity-post-case-privacy.php
  3. Then, add the custom code below to your bp-activity-post-case-privacy.php file to make the necessary adjustments.
<script type="text/html" id="tmpl-activity-post-case-privacy">
    <div id="bp-activity-privacy-point" class="{{data.privacy}}" data-bp-tooltip-pos="up" data-bp-tooltip="<?php esc_html_e( 'Set by album privacy', 'buddyboss' ); ?>">
        <span class="privacy-point-icon"></span>
        <span class="bp-activity-privacy-status">
            <# if ( data.privacy === 'group' ) { #>
                <?php esc_html_e( 'Group', 'buddyboss' ); ?>
            <# } else if ( data.privacy === 'friends' ) { #>
                <?php esc_html_e( 'My Connections', 'buddyboss' ); ?>
            <# } else if ( data.privacy === 'onlyme' ) { #>
                <?php esc_html_e( 'Only Me', 'buddyboss' ); ?>
            <# } else { #>
                <?php esc_html_e( 'All Members', 'buddyboss' ); ?>
            <# } #>
        </span>
        <i class="bb-icon-f bb-icon-caret-down"></i>
    </div>
</script>
  1. Use this CSS to hide it from privacy options and also disable the already selected privacy in activity list

Please follow the steps below:

  1. Go to BuddyBoss > Theme Options
  2. Under Custom Codes, enable CSS
  3. Append the following:
body.activity #activity-post-form-privacy label[for="public"] {
    display: none;
}

body.activity .bb-media-privacy-wrap .activity-privacy li[data-value="public"] {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
}
  1. Use this JS scripts to handle the default privacy instead of public to “loggedin” 

Please follow the steps below:

  1. Go to BuddyBoss > Theme Options
  2. Under Custom Codes, enable JavaScript
  3. Append the following:
jQuery(document).ajaxSend(function(event, jqXHR, options) {
    if (
        options.url.includes('wp-admin/admin-ajax.php') &&
        options.type === "POST" &&
        options.data.includes('privacy=public') &&
        options.data.includes('action=post_update')
    ) {
        // Replace the privacy "public" with "loggedin"
        options.data = options.data.replace('privacy=public', 'privacy=loggedin');
    }
});
  1. Save Changes.

Note: Any modifications are considered as custom work already. Know more about our Support policy here: https://www.buddyboss.com/support-policy/

Was this article helpful?

Related Articles

Related Helpful Links

Subscribe to Our Newsletter

Stay In Touch

Subscribe to our Newsletter, and we’ll send you the latest news from BuddyBoss

  • This field is hidden when viewing the form
  • This field is for validation purposes and should be left unchanged.

Need Support?

Can't find the answer you're looking for?
Support

Test Sidebar

To speak to our Agency consultant, fill in the form found at our Contact Page.

"*" indicates required fields

Get Started

Enter your name and email address to get started with your project...

Name*
Profile photo of
Not recently active