Function Reference: geodir_buddypress_author_link

Summary

buddypress author link.

Package

GeoDirectory_BuddyPress_Integration

Parameters

$link
(string) (required) Author page link.

Default: None
$user_id
(string|int) (required) User ID.

Default: None
$post_type
(string) (required) post_type of the listing.

Default: None
$force_type
(bool) (required) Todo: Explain this.

Default: None
$force_logged
(bool) (required) Todo: Explain this.

Default: None

Return Values

(string)
  • Modified link.

Change Log

Since: 1.0.0

Source File

geodir_buddypress_author_link() is located in geodir_buddypress/includes/gdbuddypress_functions.php [Line: 423]

Source Code

function geodir_buddypress_author_link( $link, $user_id = '', $post_type = '', $force_type = false, $force_logged = false ) {
	if ( get_option( 'geodir_buddypress_link_listing' ) ) {
		
		$user_id = (int)$user_id ? $user_id : '';
		if ( !$user_id && $force_logged && is_user_logged_in() ) {
			$user_id = bp_loggedin_user_id();
		}
		
		if ( $user_id && $user_domain = bp_core_get_user_domain( $user_id ) ) {
			$link = trailingslashit( $user_domain );
		}
		
		$gd_post_types = geodir_get_posttypes( 'array' );
		$listing_post_types = get_option( 'geodir_buddypress_tab_listing' );
		
		if ( $force_type && $post_type != '' && !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'];
			
			$link = trailingslashit( $user_domain . $parent_slug . '/' . $post_type_slug );
		}
	}
	
	return $link;
}