Skip Navigation

[Resolved] Sending inquiry to multiple emails with one form

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to send emails to multiple emails address at once.

Solution:

Actually this can be done by using our view plugins and the Toolset Forms generic fields.

The customer share their solution here:
https://toolset.com/forums/topic/sending-inquiry-to-multiple-emails-with-one-form/#post-894236

This support ticket is created 6 years, 5 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 10 replies, has 2 voices.

Last updated by Aquila Heman 6 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#883381

I am trying to:
I am trying to get e mail address from selected list of dealers to CRED email field with comma separation to send inquiries to all of selected dealers emails.
I got the list using javascript but I can't insert it to CRED email field

More details:
1) I have created a site with listing of equipments brands. And under that brand I have listed brand dealers. ( brand is parent and dealers are child posts)
2) When user goes to any of brand details post it have that brand dealers with under country and service type filters.( I used view for this)
3) from the list of dealers, user can select any of dealers he like to send inquiries by selecting check boxes. (I followed product comparison system for this)
4) after selecting dealers user can click on message button which leaded to another page with selected dealers and CRED form for messaging.
5) in that form I got all the emails of dealers in to comma separated list with javascript.
But I can't get that list into CRED form email field.

Link to a page where the issue can be seen:
hidden link
Select the dealers and click message button to go to multiple message form.

I expected to see:
Email list on CRED form email field

Looking forward to get solution.
Thank you.

#884461

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Aquila,

Thank you for contacting our support forum.

So essentially here you want to send a message to the brand is that correct?

Also is the message form on this page here hidden link

Thanks,
Shane

#885015

Hi Shane,

Thanks for replying.
No actually messaging brand and sending a message to a single email address is ok.

Note: Sorry you cant see massaging form without registration I will open the access to guests for the main form please check this link hidden link?

In above link, you will see a list of dealers and the CRED form (This list basically coming from brands post dealer selection, but on this link, you will see all the dealers). Top of the form there is an HTML form field with an email list that is actually taken from the above-listed dealers view using javascript.
So I need to get this list into the first email field of CRED form so that user can send an inquiry to all the dealers at once.

Javascript code I used:

var inputs = document.getElementsByClassName( 'email' ),
    names  = [].map.call(inputs, function( input ) {
        return input.value;
    }).join( ',' );

document.getElementById("emaillist").value= names;

Hope you understand what I am trying to tell.

Thank you.

#885664

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Aquila,

From the link above I see that you are trying to send the information to multiple email addresses,

Unfortunately you can only send to one email address, unless those addresses were entered in the CRED form message settings directly.

So I was assuming that the only email that the message should be sent to was the parent, which is possible with some custom code.

Please let me know.

Thanks,
Shane

#886910

Hi Shane,

Actually I need to send this emails from this form to multiple email addresses.
If you're saying that can't send emails to multiple email addresses:
I already tried it with entering email addresses manually with comma separation, and it's works.( only comma no spaces. An I have set notifications setting to this email list to be Bcc and Send notification to a specific email address as a To: Into fixed email address.

I got this email address from CPT called dealers which are parents of this form using javascript. So i am trying to get that lis into value of email field in this CRED form. Is it not possible with JS or php? ( right now I ask customers to copy and past the email list.) ☺️

Or, can you suggest any other way to do this task. But I must send this emails to multiple email addresses.

Thank you.

#889520

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Aquila,

Where is this list currently stored?

#889523

Hi Shane,

Each email address belongs to CPT called dealers. I got that email list to this form from view.

#890466

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Aquila,

Then why not pass the value from the view directly into the field?

This should be possible to do. Are you using a generic email field in CRED?

Please let me know.
Thanks,
Shane

#891300

Is it possible to pass multiple email addresses to one field with comma separation? I tried but did not got success on that. I can get online one email address. Please let me know if there is a way to do that.
I didn't use any generic fields, I used only form fields.
Thank you.

#893154

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Aquila,

Take a look at this link below.
https://toolset.com/forums/topic/method-for-user-to-choose-post-as-favorite/#post-893150

I've outlined something similar on how to do this.

Please let me know if this is clear for you.

Thanks,
Shane

#894236

Hi Shane,

Thank you very much for your solution. I did some changes to codes and now its works perfectly.
My view code is:

<!-- wpv-loop-start -->
	<wpv-loop>
          [wpv-item index=1]
              [types field='email' output='raw'][/types]
          [wpv-item index=other]
             ,[types field='email' output='raw'][/types]
        </wpv-loop>
	<!-- wpv-loop-end -->

My PHP code is: Your code didnt work but I found this one and its works (maybe some unwonted parts also in this code).

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 10, 3);
 
function prefix_clean_view_output( $out, $id ) {
  if ( $id == '773' ) { //Please adjust to your Views ID
    $start = strpos( $out, '<!-- wpv-loop-start -->' );
    if (
      $start !== false
      && strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
    ) {
      $start = $start + strlen( '<!-- wpv-loop-start -->' );
      $out = substr( $out , $start );
      $end = strrpos( $out, '<!-- wpv-loop-end -->' );
      $out = substr( $out, 0, $end );
    } else {
      $start = strpos( $out, '>' );
      if ( $start !== false) {
        $out = substr( $out, $start + 1 );
        $end = strpos( $out, '<' );
        $out = trim(substr( $out, 0, $end ));
      }
    }
  }
  return $out;
} 

Thank you again and its really nice to work with you.
Aquila Heman