bp_get_user_firstname( string|bool $name = false )

Output the first name of a user.

Description

Simply takes all the characters before the first space in a name.

Parameters

$name

(Optional) Full name to use when generating first name. Defaults to displayed user's first name, or to logged-in user's first name if it's unavailable.

Default value: false

Return

(string)

Source

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

	function bp_get_user_firstname( $name = false ) {

		// Try to get displayed user.
		if ( empty( $name ) )
			$name = bp_get_displayed_user_fullname();

		// Fall back on logged in user.
		if ( empty( $name ) )
			$name = bp_get_loggedin_user_fullname();

		$fullname = (array) explode( ' ', $name );

		/**
		 * Filters the first name of a user.
		 *
		 * @since BuddyPress 1.2.0
		 *
		 * @param string $value    First name of user.
		 * @param string $fullname Full name of user.
		 */
		return apply_filters( 'bp_get_user_firstname', $fullname[0], $fullname );
	}

Changelog

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