Skip to content

Instantly share code, notes, and snippets.

@imath
Created April 2, 2023 06:13
Show Gist options
  • Save imath/13a6b03a6ec9c362818d1045c64bba2d to your computer and use it in GitHub Desktop.
Save imath/13a6b03a6ec9c362818d1045c64bba2d to your computer and use it in GitHub Desktop.
Filter to override the BP Attachments private directory
<?php
/**
* BP Attachments overrides.
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Changes the Private directory path in favor of:
* `/wp-content/uploads/buddypress/private`.
*
* NB: you need to take care of privacy by yourself in this case.
*
* @return string Path to the private directory.
*/
function return_bp_attachments_private_dir_override() {
return trailingslashit( bp_attachments_uploads_dir_get( 'basedir' ) ) . 'private';
}
add_filter( 'bp_attachments_pre_get_private_root_dir', 'return_bp_attachments_private_dir_override' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment