Client Name not populating First Name and Last Name
-
I tried the code from the other post that is closed now and it works kind of. But the way it works is I have to have a first name field [sliced_client_fname] and last name field [sliced_client_lname] and filling those two out then combine together and fill out all three fields. However, that’s not what I want. I want to just fill out the full name field and then split it. I found a solution here on stackoverflow. However, I was wondering if someone could throw me a few pointers on how to implement it into the plugin code. Here’s the relevant code (regex):
function split_name($name) { $parts = array(); while ( strlen( trim($name)) > 0 ) { $name = trim($name); $string = preg_replace('#.*\s([\w-]*)$#', '$1', $name); $parts[] = $string; $name = trim( preg_replace('#'.$string.'#', '', $name ) ); } if (empty($parts)) { return false; } $parts = array_reverse($parts); $name = array(); $name['first_name'] = $parts[0]; $name['middle_name'] = (isset($parts[2])) ? $parts[1] : ''; $name['last_name'] = (isset($parts[2])) ? $parts[2] : ( isset($parts[1]) ? $parts[1] : ''); return $name; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Client Name not populating First Name and Last Name’ is closed to new replies.