Tell us what you are trying to do?
I wish to send user registration email notification to a dynamic list of user managers.
My list view creates a filtered list of user emails comma delimited.
Placing the shortcode as shown in the image attached does not work. I have also tried placing the view inside the registration form but there is no option to select it as a source for email list.
Is there any documentation that you are following?
Is there a similar example that we can see?
Please see image attached
What is the link to your site?
Hi, unfortunately that input field isn't flexible enough to support a View as the source for email addresses. However, we do provide an API function that can be used to manipulate the email recipients list programmatically: cred_notification_recipients. You can find the documentation for this API available here:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
Here's an example showing how to add a single recipient via CC:
add_filter('cred_notification_recipients', 'modify_recipients', 10, 4);
function modify_recipients($recipients, $notification, $form_id, $post_id) {
// Check notification name matches target notification
if ( isset($notification['name']) && 'Your notification name' == $notification['name'] ) {
// Add a CC to log@emailaddress.com
$recipients[] = array(
'to' => 'cc',
'address' => 'log@emailaddress.com',
'name' => '',
'lastname' => ''
);
}
return $recipients;
}
If you want to use the results of a View to define a group of email addresses, we have a PHP API available for that as well:
https://toolset.com/documentation/programmer-reference/views-api/#get_view_query_results
With this API you can loop over the results and take some action with each one, like so:
// Get the results of the View with ID equal to 40 and add the post titles to an array:
$filtered_posts = get_view_query_results( 40 );
$array = array();
foreach ( $filtered_posts as $filtered_post ) {
$array[] = $filtered_post->post_title;
}
So you could combine these two examples to get the results of your View, and add each of those results into the recipients array. Let me know if you need additional assistance with that, I'm not sure of your PHP skill level so this is a general reference.
My issue is resolved now. Thank you!