php - Two issues while trying to update wordpress user meta -
i have form submitting data php script. here of code in script.
foreach ($newuser_values $key => $value) { echo $key; echo $value; switch ($key) { case "show_name": echo "1"; switch ($value) { case "first": $update_val = $current_user->user_firstname; break; case "first_initial": echo "hi"; $update_val = $current_user->user_firstname . " " . substr($current_user->user_lastname,0,0) . "."; break; case "first_last": $update_val = $current_user->user_firstname . " " . $current_user->user_lastname; break; default: echo "hello"; $update_val = $user_identity; } echo $update_val; update_user_meta($user_id, $show_name, $update_val); echo get_user_meta($user_id, $show_name); ... } }
$newuser_values array of form info. this:
$newuser_values = $_post['edit-profile'];
i have 2 issues here. can both seen beginning of script output (from echo statements). script output is:
show_namefirst_intital1hellotestuser1array
problem 1: can see, script prints 1 means entering case titled "show_name" of switch on $key. however, not enter case entitled "first_intial" of switch on $value. why this?
problem 2: anyway script enters default case of switch on $value , prints hello. then, prints $update_val testuser1. however, value not getting assigned user_meta because printing "array". why this?
thanks in advance. apologize if these questions simplistic. pretty new wordpress , web development.
it seems cause of first issue typo. wrote script prints
show_namefirst_intital1hellotestuser1array
so seems there typo value of $value "first_intital" instead of "first_initial" check in switch case.
Comments
Post a Comment