The username element you are trying to access is itself a member of an array called "user" You need to use $_POST['user']['username']
Undefined index when trying to echo array element
-
30-06-2022 - |
Question
I have what will probably turn out to be major noob error. I have an array under $_POST that displays the following when I var_dump it:
array(4) { ["user"]=> array(2) { ["username"]=> string(9) "webmaster" ["email"]=> string(24) "webmaster@go-upsmart.com" } ["_wpnonce_add-user"]=> string(10) "d7ba190414" ["_wp_http_referer"]=> string(30) "/wp-admin/network/user-new.php" ["add-user"]=> string(8) "Add User" }
The part that I'm interested in is the ["username"]=> string(9) "webmaster"
But when I try to get it using a $_POST['username'], I get a Undefined index: username
It's gotta be right under my nose, could someone help me connect the dots?
Many thanks in advance for any attempts.
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow