How to redirect a page on joomla 1.6

We can use the following example to redirect a page if user is logged in or not. The following code can be put on the corresponding components or on module.

$redirect_url = JURI::getInstance()->toString(); //this JURI::getInstance()->toString() gives site url. You can replace it with any of your required url like registration page.
	$user  = & JFactory::getUser();
	If ( $user->id ) {  //if user is logged in 
		//do something
	}  else  {
		$redirect_url  =  str_replace('&','&', $redirect_url); // get rid of any ampersands
		$redirect_url  =  JRoute::_($redirect_url);
		$redirect_url  =  str_replace('&','&', $redirect_url); // get rid of any ampersands again
		$app  = & JFactory::getApplication();
		$app->redirect($redirect_url); //redirect 
	}

Redirect subscribe user to home page

Using wordpress hook, we can redirect subscribed user after login to the desired page or home page:
example:

<?php
// redirect subscribers to the home page 
function change_login_redirect($redirect_to, $request_redirect_to, $user) {
  if (is_a($user, 'WP_User') && $user->has_cap('edit_posts') === false) {
    return get_bloginfo('url'); //we can put whatever url to redirect    
  }
  return $redirect_to;
}
 
// add filter with default priority (10), filter takes (3) parameters
add_filter('login_redirect','change_login_redirect', 10, 3);
?>

avoid user validation on buddypress

In buddypress, by default user becomes non active during registration. We can avoid the validation using hook as below in functions.php inside theme file:

<?php
add_action('bp_core_signup_user','change_bp_user_status');

function change_bp_user_status ( $user_id ) {
global $bp, $wpdb;
/* Update the user status to '2' which we will use as 'not activated' (0 = active, 1 = spam, 2 = not active) */
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_status = 2 WHERE ID = %d", $user_id ) );

}	
?>