Intro
In MediaPress, the Sitewide Gallery displays the Gallery names under the thumbnails. When a user submits a photo via the Activity Feed, the album is named “Wall Gallery”
This fix will append the User or Group name so that it will be “[username]’s Walll Gallery”.
Pre-requisites
You can put this code in ‘bp-custom.php’ file. For more info check the following URL for bp-custom.php.
bp-custom.php is a php file that is loaded before BuddyPress loads anything else. In other words, The BuddyPress plugins looks for the presence of bp-custom.php in the plugins directory and if it is present, It is loaded. After that, BuddyPress continues loading the core components. If you don’t have this file in your wp-content/plugins directory, please create a file named bp-custom.php there to add the custom codes.
Once created, put the following in:
<?php
// your php custom code goes below this line.
add_action( 'mpp_before_gallery_entry', 'buddydev_modify_gallery_title' );
remove_action( 'mpp_after_gallery_entry', 'buddydev_modify_gallery_title', 10 );
function buddydev_modify_gallery_title() {
add_filter( 'mpp_get_gallery_title', function ( $title, $gallery_id ) {
if ( mpp_is_gallery_directory() && mpp_is_wall_gallery( $gallery_id ) ) {
$gallery = mpp_get_gallery( $gallery_id );
if ( 'groups' === $gallery->component ) {
$title = sprintf( '%s wall gallery', bp_get_group_name( $gallery->component_id ) );
} else {
$title = sprintf( '%s wall gallery', bp_core_get_user_displayname( $gallery->user_id ) );
}
}
return $title;
}, 10, 2 );
}
Alternate (later fix appending ” ‘s ” to user or group name with \’ character )
<?php
// your php custom code goes below this line.
/* MediaPress - Change the Gallery name from "Wall Gallery" to [username]'s gallery in both BuddyPress Gallery and Site Gallery with shortcode */
add_action( 'mpp_before_gallery_entry', 'buddydev_modify_gallery_title' );
add_action( 'mpp_before_gallery_shortcode_entry', 'buddydev_modify_gallery_title' );
remove_action( 'mpp_after_gallery_entry', 'buddydev_modify_gallery_title', 10 );
remove_action( 'mpp_after_gallery_shortcode_entry', 'buddydev_modify_gallery_title', 10 );
function buddydev_modify_gallery_title() {
add_filter( 'mpp_get_gallery_title', function ( $title, $gallery_id ) {
if ( mpp_is_wall_gallery( $gallery_id ) ) {
$gallery = mpp_get_gallery( $gallery_id );
if ( 'groups' === $gallery->component ) {
$title = sprintf( '%s\'s wall gallery', bp_get_group_name( $gallery->component_id ) );
} else {
$title = sprintf( '%s\'s wall gallery', bp_core_get_user_displayname( $gallery->user_id ) );
}
}
return $title;
}, 10, 2 );
}
Save the changes and then try it out.


Leave a Reply