Created
August 29, 2018 11:28
-
-
Save pranali333/149fd3480765b2c09b2a383b9c3d9d59 to your computer and use it in GitHub Desktop.
Keep the Media tab open while visiting BuddyPress group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This snippet can be used for redirecting users to the BuddyPress group Media tab when clicking on the group name. | |
* You can use this code under your theme's functions.php file: | |
*/ | |
function bp_change_group_link( $link ) { | |
preg_match_all( '~<a(.*?)href="([^"]+)"(.*?)>~', $link, $matches ); | |
$link_changed = preg_replace( "/(?<=href=(\"|'))[^\"']+(?=(\"|'))/", $matches[2][0] . apply_filters( 'rtmedia_media_tab_slug', 'media' ), $link ); | |
return $link_changed; | |
} | |
add_filter( 'bp_get_group_link', 'bp_change_group_link' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can checkout sample output here: