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 Description

Eg: Andy Peatling

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


Top ↑

Parameters 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


Top ↑

Return Return

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


Source 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 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="' . esc_url( $url ) . '">' . $display_name . '</a>', $user_id );
}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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