[SOLVED] Email form

2 years 3 months ago #327671 by galanopd
Replied by galanopd on topic Email form

For onAfterEmailUserForm you'd just be using an HTML code action and output your checkboxes by setting Mode to Return under the Output tab.

Here is what I did
1.
Global->Triggers: None
Conditions->Field: None
Action->Method: HTML
Action->Code:
$_PLUGINS->trigger( 'onAfterEmailUserForm', array( &$rowFrom, &$rowTo, &$warning, 1, &$allowPublic, &$name, &$email, &$subject, &$message ) );
Output->Display: Return
Output->Layout:
<div class="input-group mb-2"><span class="ml-1 fas fa-tasks fa-2x">&nbsp;</span><div class="input-group-append"><div class="input-group-text">You have selected to contact this user using the following options: &nbsp; [cb:userfield field="cb_profile_email_options1" /]</div></div></div>
Method: HTML
Translate: No
Substitutions: Yes
Format functions: No
Content Plugins: No

Here is what I get


I get the field but only the result "∅". This is what I have set for empty fields. In other words this
[cb:userfield field="cb_profile_email_options1" /]
doesn't call the checkboxes (I definitely do something wrong, I know)

2.

For onBeforeEmailUser you need to set Variable 7 as a Reference Variable under Parameters then use a PHP code action to modify that variable using $variables to add your checkbox value to the message being emailed.


Is there an example or documentation on how to implement this with $variables in CB Auto Actions? Although novice, I am trying to understand and learn (never too late in life) how it works.

Thank you for your help Kyle
Attachments:

Please Log in to join the conversation.

2 years 3 months ago #327672 by krileon
Replied by krileon on topic Email form
Ideally you should have the below 2 auto actions for example.

Global
Triggers: onAfterEmailUserForm
Type: Code
User: Automatic
Access: Everybody
Action
Method: HTML
Code:
<input type="text" name="emailoptions" class="form-control" />
Output
Display: return

Global
Triggers: onBeforeEmailUser
Type: Code
User: Automatic
Access: Everybody
Action
Method: PHP
Code:
$variables['var7'] = '[var7] [cb:parse function="clean" method="string"][post_emailoptions][/cb:parse]';
Parameters
Format Functions: Yes
References: Variable 7

The first auto action adds a text input. The second auto action adds the value of that text input to the email. The text input is also being sanitized to string for security. If you need checkboxes, a select field, etc.. then adjust the HTML as needed. You'll notice in the second auto action you can grab values sent with the form via [post_INPUT_NAME] substitution usage. In my example the input name is emailoptions, which means it's accessed with [post_emailoptions].


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

2 years 2 months ago #327726 by galanopd
Replied by galanopd on topic Email form
First of all Happy New Year and all the best to you and to all the Joomlapolis team!

Just for me to understand better. The HTML Auto Action you have provided for onAfterEmailUserForm creates a select field to the form and does not "call" an already existing one using cb_substitution, correct? According to this I have created the following
<div class="row">
   <div class="col-md-6 col-sm-6">
      <div class="form-group">
         Available contact options
         <select class="form-control" name="emailoptions" required>
            <option value="" selected disabled>Please select one of the options below</option>
            <optgroup style="font-weight: bolder" label="Type 1">
               <option value="1">1</option>
               <option value="2">2</option>
               <option value="3">3</option>
            </optgroup>
            <optgroup style="font-weight: bolder" label="Type 2">
               <option value="4">4</option>
               <option value="5">5</option>
               <option value="6">6</option>
               <option value="7">7</option>
            </optgroup>
         </select>
      </div>
   </div>
</div>
<hr />
This works fine and I get what I want but when I complete the form I do not get the expected result in the received email when using the following in the PHP in onBeforeEmailUser
$variables['var7'] = '[var7] [cb:parse function="clean" method="string"][post_emailoptions][/cb:parse]';

Please Log in to join the conversation.

2 years 2 months ago #327740 by krileon
Replied by krileon on topic Email form

First of all Happy New Year and all the best to you and to all the Joomlapolis team!

Thank you! Hope you have a wonderful new year as well! :)

Just for me to understand better. The HTML Auto Action you have provided for onAfterEmailUserForm creates a select field to the form and does not "call" an already existing one using cb_substitution, correct? According to this I have created the following

Correct, you need to provide the full HTML structure of the field you want rendered. So if that's a select field then you need to provide the select fields HTML.

This works fine and I get what I want but when I complete the form I do not get the expected result in the received email when using the following in the PHP in onBeforeEmailUser

It worked fine in my tests. What are you receiving in the email? Is it not adding your custom field to the email message? It should be right after the user supplied message, which you can of course change it to be before or add line breaks in that code auto action.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

2 years 2 months ago - 2 years 2 months ago #327752 by galanopd
Replied by galanopd on topic Email form

It worked fine in my tests. What are you receiving in the email? Is it not adding your custom field to the email message? It should be right after the user supplied message, which you can of course change it to be before or add line breaks in that code auto action.

I must be doing something wrong then... Here is what I get in my email.
------- This is a message from Testos at Xcompany to you: -------

[var7] [cb:parse function="clean" method="string"][post_emailoptions][/cb:parse]

------ NOTES: ------

When replying, please check carefully that the email address of Testos is test@testemail.com.

This user did not see your email address. If you reply the recipient will have your email address.

XCompany owners cannot accept any responsibility for the contents of the email and of user email addresses.

I have set everything according to

Global
Triggers: onBeforeEmailUser
Type: Code
User: Automatic
Access: Everybody
Action
Method: PHP
Code:

$variables = '[var7] [cb:parse function="clean" method="string"][post_emailoptions][/cb:parse]';

Parameters
Format Functions: Yes
References: Variable 7


Also, Output: return (tried none too)

Please Log in to join the conversation.

2 years 2 months ago #327756 by krileon
Replied by krileon on topic Email form
Seams like substitutions are turned off in your auto action. Under Parameters ensure Substitutions is set to Yes. That should be default Yes. Format functions also needs to be toggled to Yes (default No).


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: galanopd

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.199 seconds

Facebook Twitter LinkedIn