Function Reference: geodir_buddypress_author_redirect

Summary

Redirect away from gd dashboard to BP registration profile page.

Package

GeoDirectory_BuddyPress_Integration

Parameters

$body_class
(string) (required) HTML body class.

Default: None

Change Log

Since: 1.0.0

Source File

geodir_buddypress_author_redirect() is located in geodir_buddypress/includes/gdbuddypress_functions.php [Line: 1416]

Source Code

function geodir_buddypress_author_redirect($body_class) {
	$gd_dashboard = isset( $_REQUEST['geodir_dashbord'] ) ? true : false;
	$favourite = isset( $_REQUEST['list'] ) && $_REQUEST['list'] == 'favourite' ? true : false;
	$post_type = isset( $_REQUEST['stype'] ) ? $_REQUEST['stype'] : NULL;
	
	// gd dashboard page
	if ( $gd_dashboard && get_option( 'geodir_buddypress_link_listing' ) ) {
		$author = get_query_var( 'author_name' ) ? get_user_by( 'slug', get_query_var( 'author_name' ) ) : get_userdata( get_query_var( 'author' ) );
		
		if ( $favourite && !get_option( 'geodir_buddypress_link_favorite' ) ) {
			return;
		}
		
		if ( !empty( $author ) && isset( $author->ID ) && $author_id = $author->ID ) {
			if ( $author_id && $user_domain = bp_core_get_user_domain( $author_id ) ) {
				$author_link = trailingslashit( $user_domain );
				
				if ( $post_type != '' ) {
					$gd_post_types = geodir_get_posttypes( 'array' );
					$listing_post_types = get_option( 'geodir_buddypress_tab_listing' );
					
					if ( !empty( $gd_post_types ) && array_key_exists( $post_type, $gd_post_types ) && !empty( $listing_post_types ) && in_array( $post_type, $listing_post_types ) && $user_domain ) {
						$parent_slug = 'listings';
						$post_type_slug = $gd_post_types[$post_type]['has_archive'];
						
						$author_link = trailingslashit( $user_domain . $parent_slug . '/' . $post_type_slug );
					}
				}
				
				wp_redirect( $author_link );
				exit;
			}
		}
	}
	return;
}