Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Created February 7, 2017 14:47
Show Gist options
  • Save raftaar1191/32d02614d4f48f1e7b6ee660869ae38f to your computer and use it in GitHub Desktop.
Save raftaar1191/32d02614d4f48f1e7b6ee660869ae38f to your computer and use it in GitHub Desktop.
Redirect user to media page when user click on profile picture
<?php
/**
* rtmedia_bp_get_activity_user_link_callback Change the User link to User Media link
*
* @param [type] $link Original link of the Author
*/
function rtmedia_bp_get_activity_user_link_callback( $link ) {
// copy original link to new variable
$new_link = $link;
// check is slug Constants is define or not
if ( defined( 'RTMEDIA_MEDIA_SLUG' ) ) {
$add_url = RTMEDIA_MEDIA_SLUG;
} else {
$add_url = 'media';
}
// add forward slash to new slug
$add_url = $add_url . '/';
// get login user id
$get_current_user_id = get_current_user_id();
// check if user is login or not
if ( ! empty( $get_current_user_id ) ) {
global $activities_template;
// check of login user if and activity author id is not same
if ( $activities_template->activity->user_id != $get_current_user_id ) {
// uddate the slug is not same
$new_link = $new_link . $add_url;
}
} else {
// if user is not login in then directly change the slug
$new_link = $new_link . $add_url;
}
// return the new author link
return $new_link;
}
add_filter( 'bp_get_activity_user_link', 'rtmedia_bp_get_activity_user_link_callback', 10, 1 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment