To remove the "Public" option, we need to override the template and add some custom code. Here's how to do it:
Key Steps:
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.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.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:
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.phpTo 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.phpThen, 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>
4. Use this CSS to hide it from privacy options and also disable the already selected privacy in activity list
Please follow the steps below:
Go to BuddyBoss > Theme Options
Under Custom Codes, enable CSS
- 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;
}
5. Use this JS scripts to handle the default privacy instead of public to “loggedin”
Please follow the steps below:
Go to BuddyBoss > Theme Options
Under Custom Codes, enable JavaScript
- 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');
}
});
- Save Changes.
Note: Any modifications are considered as custom work already. Know more about our Support policy here: https://www.buddyboss.com/support-policy/
Did you find it helpful? Yes No
Send feedbackSorry we couldn't be helpful. Help us improve this article with your feedback.