• ashop59

    (@ashop59)


    Hello, I hope you can help me, I thank you in advance.

    I have a variable with many values, they are emails obtained from a subscription form that I created and what I need is to get those emails to send them with wp_mail but I don’t know how to do it.

    at the moment I have this:
    $ emails_all_subscription = get_user_meta ($ vendor_id, ‘subscribers3’, true);

    echo “

    ";
    var_export ($ emails_all_subscription);
    echo "

    “;

    and the result is like this:

    array (
    0 =>
    array (
    0 =>
    array (
    0 =>
    array (
    0 =>
    array (
    0 => ‘[email protected]’,
    ),
    1 => ‘[email protected]’,
    ),
    1 => ‘[email protected]’,
    ),
    1 => ’22 @ gmail.com ‘,
    ),
    1 => ’44 @ gmail.com ‘,
    )

    I only need to see the 5 emails or pass the 5 (and those that are added through the form) to wp_mail.

    Surely it is very simple but I do not realize among so many options that there seem to be to display an array.

    Thank you

    • This topic was modified 3 years ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 5 replies - 1 through 5 (of 5 total)
  • catacaustic

    (@catacaustic)

    It’s not too hard. Just loop through them and save the values.

    As a completely untested example:

    $email_list = array ();
    
    foreach ($emails_all_subscription as $row) {
        foreach ($row as $email) {
            if (empty ($email) === false) {
                $email_list [] = $email;
            }
        }
    }
    
    wp_mail ($email_list, 'Subject', 'Email content');

    This assumes that the data structure that you’ve givne above won’t change, and the value comes our as an array of arrays.

    Thread Starter ashop59

    (@ashop59)

    hello, thank you very much for your help. unfortunately it does not work for me, it does not send emails but it does not return the values to the echo $ email_list either. I’ll keep seeing what I can do, thank you

    Thread Starter ashop59

    (@ashop59)

    this is how I save the values maybe this will help:

    if (isset ($ _ POST [‘sub_sus’])) {

    $ email_suscriptores2 = $ _POST [’email_sus’];

    $ subscriber_list2 = get_user_meta ($ vendor_id, ‘subscribers3’, false);

    if (! array ($ subscriber_list2)) {
    $ subscriber_list2 = array ();
    }

    $ subscriber_list2 [] = $ email_subscribers2;

    update_user_meta ($ vendor_id, ‘subscribers3’, $ subscriber_list2);

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @ashop59 I have archived your FIVE duplicate topics. Stop doing that OK?

    Thread Starter ashop59

    (@ashop59)

    Yes, I agree, but it is that he adds information in each one even if he talks about the same thing. well, thank you but you didn’t give me any help

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘get values (emails) from an array and pass them to wp_mail’ is closed to new replies.