I display a page with a list of users using this loop:
foreach ($mytaxonomies as $mytaxonomy) : setup_postdata($mytaxonomy);
echo $mytaxonomy->name; // print the name of the user
echo '<a>Send email</a>';
endforeach;
the object $mytaxonomy
contains many values like the email of the current user in $mytaxonomy->email
Clicking on the link (Send email) shows a modal overlay with a form to send an email to that user.
The form sends the mail to the email address specified in the variable $to
but I'm not able to assign the $mytaxonomy->email
to that variable (depending on which link was clicked).
I need a thing like
<?php $to = $mytaxonomies[...]->email; ?>
where $mytaxonomies[...]->email
changes everytime I click on a different user (because obviously each user have a different email).
EDIT: $mytaxonomies is the array that containes all the users with their infos
print_r($mytaxonomies);
Array
(
[0] => stdClass Object
(
[term_id] => 4
[name] => John Doe
[slug] => john-doe
[email] => johndoe@email.com
[age] => ...
[phone] => ...
)
[1] => stdClass Object
(
[term_id] => 5
[name] => Jane Doe
[slug] => jane-doe
[email] => jdoe77@converge.con
[age] => ...
[phone] => ...
)
...
)