bp_get_members_component_link( string $component, string $action = '', array|string $query_args = '', array|bool $nonce = false )

Generate a link to a members component subpage.

Description

Parameters

$component

(Required) ID of the component (eg 'friends').

$action

(Optional) 'action' slug (eg 'invites').

Default value: ''

$query_args

(Optional) Array of URL params to add to the URL. See add_query_arg() for format.

Default value: ''

$nonce

(Optional) If provided, the URL will be passed through wp_nonce_url() with $nonce as the action string.

Default value: false

Return

(string)

Source

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

	function bp_get_members_component_link( $component, $action = '', $query_args = '', $nonce = false ) {

		// Must be displayed user.
		if ( !bp_displayed_user_id() )
			return;

		$bp = buddypress();

		// Append $action to $url if there is no $type.
		if ( !empty( $action ) )
			$url = bp_displayed_user_domain() . $bp->{$component}->slug . '/' . $action;
		else
			$url = bp_displayed_user_domain() . $bp->{$component}->slug;

		// Add a slash at the end of our user url.
		$url = trailingslashit( $url );

		// Add possible query arg.
		if ( !empty( $query_args ) && is_array( $query_args ) )
			$url = add_query_arg( $query_args, $url );

		// To nonce, or not to nonce...
		if ( true === $nonce )
			$url = wp_nonce_url( $url );
		elseif ( is_string( $nonce ) )
			$url = wp_nonce_url( $url, $nonce );

		// Return the url, if there is one.
		if ( !empty( $url ) )
			return $url;
	}

Changelog

Changelog
Version Description
BuddyPress 1.5.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.