You have to add action to, for example, template_redirect
action hook. The action would perform your desired checks and redirect user using the wp_redirect()
function. The code could look something like this:
function my_redirect_function() {
// Check if home page is being displayed
if ( is_home() ) {
global $userdata;
get_currentuserinfo();
$username = $userdata->user_login;
$url="http://my.url.org/mentions/" . $username;
wp_redirect( $url );
exit;
}
}
add_action( 'template_redirect', 'my_redirect_function' );
You place whatever checks (such as conditional tags) you’d like instead of is_home()
check.