Filtering empty WordPress custom fields for email list

Hello Make Community,

In my scenario I am:

  1. pulling data from WordPress posts,
  2. creating a spreadsheet,
  3. updating the Wordpress post with the spreadsheet ID,
  4. and then I want to share the spreadsheet with between 1-4 emails contained in the fields of the WordPress post.

I am struggling with point 4, as 3 of the email fields are optional and thus empty at times. The Get a Share Link Module doesn’t process any of the values if one is empty. Module 4 works fine if I only add the two fields that contain an email.

The four custom fields that can contain emails look as follows in the output bundle of Module 1:

        "email_facilitator_2": "john@test.com",
        "email_facilitator_3": "",
        "email_facilitator_4": "",
        "admin_email": "jane@test.org",

In Module 4 I have added the following in the Email Address field:

I have tried a number of different solutions to filter out the empty fields, for example with a Set Variable Module. e.g.

{{join(
ifempty(1.admin_email; null);
ifempty(1.email_facilitator_2; null);
ifempty(1.email_facilitator_3; null);
ifempty(1.email_facilitator_4; null);
“,”)
}}

But have had no luck in getting it to work.

Any suggestions and support are greatly appreciated! Happy to share any more information that may be needed, if the above is insufficient.

Welcome to the Make community!

The “Email Address” field only accepts a single email address. That means you have to run this module up to four times.

Therefore, you will need to use an Iterator module with a filter after the Iterator module to check if the email exists.

Then, map the “Value” of the Iterator module into the “Email Address” field.

Hope this helps! If you are still having trouble, please provide more details.

@samliew
P.S.: investing some effort into the tutorials in the Make Academy will save you lots of time and frustration using Make!

1 Like

Wonderful - thank you for the solution Sam!

In case anyone else ends up looking at this thread, here is a more detailed explanation of how I ended up implementing Sam’s suggestion.

  1. Added an iterator that creates an array using all the email fields.

  2. Set up a filter which in my case checks each value of the array for the @ symbol.

    1. In Action:

  3. In the Google Drive module I then added the 11. Value, and in this example it successfully ran twice, ignoring the two empty values.

Hope this helps any other rookies, like myself. :slight_smile:

1 Like