bp_get_user_firstname( string|bool $name = false )

Output the first name of a user.

Description Description

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

Top ↑

Parameters Parameters


(string|bool) (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

Top ↑

Return Return


Source 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 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 );

Top ↑

Changelog Changelog

Version Description
1.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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