Routing to Mailadress of a user by ID

Hi,
I am looking for a solution on routing notifications

I have got a list of specific WP Users on page 1 and my visitor can choose one to mail him. These are about 70 users changing every week.

Now I want to open a form on page 2 (or in a lightbox) wich is to send to the choosen user.

I thought of prepopulating a hidden field with the id of the user


then sent the mail to the user mailadress or to a custom field containing another mailadress.

How to achive this step? Getting a custom field based on a field with a given user id ::
if field r = 1234 then get usermail (or ACF field value) of 1234 and send notification to it

Any better way? Any plugin?

I can´t use conditional routing as my recieverlist changes to often and is to long.

Hello Henrik. If you have a way to pass the ID or email address of the user from page 1 (the list of all users) to page 2 (the page with the form) you can populate a field in the form with that data. You would use dynamic population via the query string, as explained here:

If you are passing the email address from page 1 to page 2, into an email field, you are done. Use that email field in your notification configuration.

If you are passing the ID so that the email address is not exposed, you have one more step. That is to use the gform_notification filter to look up the email address for the user. You would use a WordPress or ACF function to look up the email address that is associated with that ID, tied to the gform_notification_filter:

The function you use to look up the email address depends on how the email address is stored. If it’s a WordPress user’s email address, then you would use a WordPress function. However, you mentioned ACF, and I can’t see why that is involved, but if the email address is stored in an ACF field, then you would use an ACF function to get the email address associated with the ID.

1 Like

Thanks Chris! I get the value of the field. I am stuck at getting the value of the ACF field hooked to the user ID - but I will find my mistake there :slight_smile:

If all you really need is the email address and not the user ID. You can just encrypt the email address and send it with a parameter in the url which is populated in your next form. Then just add the field as the send to field. To encrypt the email address you can use GFEncrypt plugin on Code Canyon.

This would bypass the need for the ID. And also encrypt the data if that’s what you’re concerned about.

I seem to be mentioning this plugin quite often.