Created
October 4, 2012 19:47
-
-
Save thefrosty/3835942 to your computer and use it in GitHub Desktop.
Returns Undefined index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$defaults = array( | |
'company' => 'client_company', | |
'address_1' => 'client_address_1', | |
'address_2' => 'client_address_2', | |
'city' => 'client_city', | |
'state' => 'client_state', | |
'postcode' => 'client_postcode', | |
'country' => 'client_country' | |
); | |
/** | |
* Parse incomming $args into an array and merge it with $defaults | |
*/ | |
$args = wp_parse_args( $args, $defaults ); | |
/** | |
* OPTIONAL: Declare each item in $args as its own variable i.e. $type, $before. | |
*/ | |
extract( $args, EXTR_SKIP ); | |
//print_r( $args ); return; | |
$user_meta = array(); | |
foreach ( $args as $label => $value ) { | |
$user_meta[$label] .= get_user_meta( $user_id, $value, true ); | |
} | |
return $user_meta; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With the $user_meta array using the $label it gives a undefined index of all the default args labels. With out the $label in the $user_meta array it's fine but outputs the count.
$user_meta[$label]:
Array
(
[company] =>
[address_1] =>
[address_2] =>
[city] =>
[state] =>
[postcode] =>
[country] =>
)
$user_meta[]:
Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
)