bp_core_get_userlink( int $user_id, bool $no_anchor = false, bool $just_link = false )

Return a HTML formatted link for a user with the user’s full name as the link text.

Description

Eg: Andy Peatling

Optional parameters will return just the name or just the URL.

Parameters

$user_id

(int) (Required) User ID to check.

$no_anchor

(bool) (Optional) Disable URL and HTML and just return full name. Default: false.

Default value: false

$just_link

(bool) (Optional) Disable full name and HTML and just return the URL text.

Default value: false

Return

(string|bool) The link text based on passed parameters, or false on no match.

Source

File: bp-members/bp-members-functions.php

function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false ) {
	$display_name = bp_core_get_user_displayname( $user_id );

	if ( empty( $display_name ) ) {
		return false;
	}

	if ( ! empty( $no_anchor ) ) {
		return $display_name;
	}

	if ( !$url = bp_core_get_user_domain( $user_id ) ) {
		return false;
	}

	if ( ! empty( $just_link ) ) {
		return $url;
	}

	/**
	 * Filters the link text for the passed in user.
	 *
	 * @since BuddyPress 1.2.0
	 *
	 * @param string $value   Link text based on passed parameters.
	 * @param int    $user_id ID of the user to check.
	 */
	return apply_filters( 'bp_core_get_userlink', '<a href="' . $url . '">' . $display_name . '</a>', $user_id );
}

Changelog

Changelog
Version Description
BuddyPress 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.