bbp_get_user_profile_url( int $user_id, string $user_nicename = '' )

Return URL to the profile page of a user


Description Description


Parameters Parameters

$user_id

(Optional) User id

$user_nicename

(Optional) User nicename

Default value: ''


Top ↑

Return Return

(string) User profile url


Top ↑

Source Source

File: includes/users/template.php

	function bbp_get_user_profile_url( $user_id = 0, $user_nicename = '' ) {

		// Use displayed user ID if there is one, and one isn't requested
		$user_id = bbp_get_user_id( $user_id );
		if ( empty( $user_id ) ) {
			return false;
		}

		// Bail if intercepted
		$intercept = bbp_maybe_intercept( 'bbp_pre_get_user_profile_url', func_get_args() );
		if ( bbp_is_intercepted( $intercept ) ) {
			return $intercept;
		}

		// Pretty permalinks
		if ( bbp_use_pretty_urls() ) {

			// Get username if not passed
			if ( empty( $user_nicename ) ) {
				$user_nicename = bbp_get_user_nicename( $user_id );
			}

			// Run through home_url()
			$url = trailingslashit( bbp_get_root_url() . bbp_get_user_slug() ) . $user_nicename;
			$url = user_trailingslashit( $url );
			$url = home_url( $url );

		// Unpretty permalinks
		} else {
			$url = add_query_arg( array(
				bbp_get_user_rewrite_id() => $user_id
			), home_url( '/' ) );
		}

		// Filter & return
		return apply_filters( 'bbp_get_user_profile_url', $url, $user_id, $user_nicename );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.