Here is what I didFor onAfterEmailUserForm you'd just be using an HTML code action and output your checkboxes by setting Mode to Return under the Output tab.
$_PLUGINS->trigger( 'onAfterEmailUserForm', array( &$rowFrom, &$rowTo, &$warning, 1, &$allowPublic, &$name, &$email, &$subject, &$message ) );
<div class="input-group mb-2"><span class="ml-1 fas fa-tasks fa-2x"> </span><div class="input-group-append"><div class="input-group-text">You have selected to contact this user using the following options: [cb:userfield field="cb_profile_email_options1" /]</div></div></div>
[cb:userfield field="cb_profile_email_options1" /]
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.
Please Log in to join the conversation.
<input type="text" name="emailoptions" class="form-control" />
$variables['var7'] = '[var7] [cb:parse function="clean" method="string"][post_emailoptions][/cb:parse]';
Please Log in to join the conversation.
<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 />
$variables['var7'] = '[var7] [cb:parse function="clean" method="string"][post_emailoptions][/cb:parse]';
Please Log in to join the conversation.
Thank you! Hope you have a wonderful new year as well!First of all Happy New Year and all the best to you and to all the Joomlapolis team!
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.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
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.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
Please Log in to join the conversation.
I must be doing something wrong then... Here is what I get in my email.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.
------- 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.
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
Please Log in to join the conversation.
Please Log in to join the conversation.