This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Hi Nigel, it looks like it should work as the option is there in notifications. I would have though that this would be a common use-case - I doubt many developers want to display email addresses on the front-end. Could you pass this through as an enhancement request/bug fix?
Out of interest, what is the user-id notification and when if ever would it normally work?
The notification to a user specified in a user_id form field is for use on a CRED User form where you can add a user id field rather than a CRED Post form where you cannot.
I'll re-assign this ticket and label as a feature request so our developers can assess whether to add it to our roadmap.
I have good news for you, or somethign like good news.
Nigel was slightly wrong: the notification to a user specified in a user_id form field of course can be used on CRED Post form, and you can indeed set a "user_id" generic type for a field. I did not test this to the end, meaning I did not check whether this indeed works and you get the email in the desired email address, but for sure this generic user_id field can be selectable in the dropdown.
Otherwise, this would not be a feature request but a bug, since we should not offer the option to a WordPress user which ID comes from a form field in post forms, if that is only meant for user forms.
But it does work. The only liitation here is that the field must be prsistent, so the "persist" property must be set to 1 instead of 0. Once you make that field persistent, it becomes available as sorce of the ID of the user that you want to notify.
I understand that making this field persistent might not match your plans, I will ask why we have this requirement.
I got an answer from our CRED development team. As I suspected, the user_id fields must be either existing or persisten genric fields, for a reason. At the moment that the form notifications are sent, the form submitted data has already been processed. That means that we stored the permanent fields and discarded and cleared the non persistent. Because of that, non persistent fields can not affect notifications in any way.
If you do not want to keep this user_id field after sending the notification, I am sure that we have some action somewhere that lets you do a cleanup afte the fact.
Hey Juan, thanks for the clarification. I've already implemented the php solution, but it is not ideal. I'll have another look at the generic field approach.
As I said, I've implemented the php solution that Nigel passed me. I'm now using a custom field for the email address - the following is a snippet from the implemented code:
//
// Get contact email for the accommodation
$ownerEmail = get_post_meta($parentPostId, 'wpcf-acc-kontakt-email', true);
$to_header = array( 'To: ' . $ownerEmail );
$headers = array_merge($headers, $to_header);
For the cred_mail_header action to be run, I need to create a valid notification (if I create the notification without a To email address, then the action is not triggered). So I have created a dummy noreply To address.
Ideally I would like to replace (ie. remove) this dummy address in the action, but I cannot see a way to do this.
It is not present in the $headers array passed to the action. I would expect to be able to modify existing addresses in the mail header - in fact $headers just contains:
(
[0] => Content-Type: text/html
)
None of the existing address details seem to be available. Perhaps this too is a bug?
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.