If I have a users username, is it possible to take that and echo their email address instead?

I have a field in Gravity Forms that has the assigned user to that job. I have added some code that echos the value of the input which is their username. How do I take that value and transform it into an echo that is their email instead? Here is the code I am working with:

    $lead_id = $entry_slug_esc;
    $lead = RGFormsModel::get_lead( $lead_id ); 
    $form = GFFormsModel::get_form_meta( $lead['form_id'] ); 

    $values= array();

    foreach( $form['fields'] as $field ) {

        $values[$field['id']] = array(
            'value' => $lead[ $field['id'] ],
    <div><?php echo $values[52]['value']; ?></div>
    // <?php echo $values[52]['value']; ?> is the username.  Instead of echoing that I want it to be that users email.

Note: I can't just change the value of that field to their email@address because I am also using it as a search param and it does not work with the @ in the url structure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.