mc4wp_add_name_data ( array $data = array() )

Guesses merge vars based on given data & current request.

Return: (array)

Source file: functions.php

View source


Parameters

$data

(array) (Optional)

Default value: array()


Used by

Uses


Source

function mc4wp_add_name_data( $data = array() ) {

	// Guess first and last name
	if ( ! empty( $data['NAME'] ) && empty( $data['FNAME'] ) && empty( $data['LNAME'] ) ) {
        $data['NAME'] = trim( $data['NAME'] );
		$strpos = strpos( $data['NAME'], ' ' );

		if ( $strpos !== false ) {
			$data['FNAME'] = trim( substr( $data['NAME'], 0, $strpos ) );
			$data['LNAME'] = trim( substr( $data['NAME'], $strpos ) );
		} else {
			$data['FNAME'] = $data['NAME'];
		}
	}

	// Set name value
	if( empty( $data['NAME'] ) && ! empty( $data['FNAME'] ) && ! empty( $data['LNAME'] ) ) {
		$data['NAME'] = sprintf( '%s %s', $data['FNAME'], $data['LNAME'] );
	}
	
	return $data;
}


Changelog

  • Since: WordPress 3.0

User Contributed Notes

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