[SOLVED] Email form

2 years 3 months ago #327844 by krileon
Replied by krileon on topic Email form
Ok, it really seams like the best way to have what you're wanting is to either develop it as a custom component or consider using a form extension. I don't see a way to string that together well with CB Auto Actions and the simple email form we provide. With that said it IS doable, but not advisable. It'll require a complicated mess of auto actions and the user experience (UX) for your users is going to be awkward.

If you absolutely want to do this with CBs email form then the below should get you started. The below renders a select field only if emailoptions doesn't exist in the URLs get values otherwise it's passed as a hidden input value. So this lets you set its value using the URL like you seam to be needing to do since it can be pre-selected externally.

Global
Triggers: onAfterEmailUserForm
Type: Code
User: Automatic
Access: Everybody
Action
Method: HTML
Code:
[cb:if get_emailoptions=""]
<select name="emailoptions" class="form-control">
	<option value="" selected="selected">Free</option>
	<option value="paid">Paid</option>
</select>
[cb:else]
<input type="hidden" name="emailoptions" value="[cb:parse function="encode" method="html"][cb:parse function="clean" method="string"][get_emailoptions][/cb:parse][/cb:parse]" />
[/cb:else]
[/cb:if]
Output
Display: return
Parameters
Format Functions: Yes

Global
Triggers: onBeforeEmailUser
Type: Code
User: Automatic
Access: Everybody
Action
Method: PHP
Code:
$option	=	null;

switch ( '[cb:parse function="clean" method="string"][post_emailoptions][/cb:parse]' ) {
	case 'paid':
		$option	=	'Paid';
		break;
	default:
		$option	=	'Free';
		break;
}

$variables['var7'] = '[var7]' . $option;
Parameters
Format Functions: Yes
References: Variable 7

It'll convert the selected dropdown value back to label and add it to the end of the email. How you want it displayed in the email is entirely up to you. You can also act on this value in other auto actions. For example you could redirect them somewhere else if they selected the paid option.

Global
Triggers: onAfterEmailUserForm
Type: Redirect
User: Automatic
Access: Everybody
Conditions
Field: Custom > Value
Custom Value: [post_emailoptions]
Operator: Equal To
Value: paid
Action
URL: PAID_URL

That would redirect them to PAID_URL if they tried to send an email with the paid option.

I think a better option though is to just not try to interrupt the email process at all. Instead always send a FREE marked email if they don't have a subscription otherwise mark them as PAID using onBeforeEmailUser. If these are 1 time purchases then that will certainly complicate things.


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.

2 years 3 months ago #327850 by galanopd
Replied by galanopd on topic Email form
Your analysis helped me get the picture a bit more. I will consider using a form extension
This message contains confidential information
and/or experiment using CB Auto Actions. I might need to combine both at some point.

Thank you Kyle, your help is always valuable
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

2 years 3 months ago - 2 years 3 months ago #327887 by galanopd
Replied by galanopd on topic Email form
How can I
  • if option 'Free' is chosen -> connect to CB email form but I can't use this link in my form option ../cb-profile/emailuser/userX# as each time will be a different user. I mean something like ../cb-profile/emailuser/[user_id]
  • if option 'Paid' is chosen -> link to the form extension (Not CB email form) but for the specific user selected on the userlist or profile. Like in the case of cb email form, when "send email" is clicked the title on top of the form says "Send a message via email to userX". I suppose it would be something like
    u.`id` = [user_id]
    Then after submitting using the form extension, the correct user will receive the email

Please Log in to join the conversation.

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

if option 'Free' is chosen -> connect to CB email form but I can't use this link in my form option ../cb-profile/emailuser/userX# as each time will be a different user. I mean something like ../cb-profile/emailuser/[user_id]

Free in my above example is the default you don't need to do anything further there. As I understand it you were using a Custom HTML field to add a link to userlists and is where you'd be using a custom URL. You'd just use the below in your Custom HTML field to link to the email form with the options value pre-set.

index.php?option=com_comprofiler&view=emailuser&uid=[user_id]&emailoptions=free

I don't recommend using both CBs email form and your form extension. Instead turn CBs off and use the form extension exclusively so it's less confusing for your users.

if option 'Paid' is chosen -> link to the form extension (Not CB email form) but for the specific user selected on the userlist or profile. Like in the case of cb email form, when "send email" is clicked the title on top of the form says "Send a message via email to userX". I suppose it would be something like

I can't help you in regards to the page title in your form extension as it'd need support for such a feature. You'll need to contact the developer of your form extension regarding this.


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 3 months ago - 2 years 3 months ago #327899 by galanopd
Replied by galanopd on topic Email form

I don't recommend using both CBs email form and your form extension. Instead turn CBs off and use the form extension exclusively so it's less confusing for your users.


You are correct in this but I think I didn't explain well what I need.
So, my question is, the
index.php?option=com_comprofiler&view=emailuser&uid=[user_id]&emailoptions=free
is using com_comprofiler to send an email to the user. It is an internal process where the visitor does not know the email address of the user. Now, if I need to use a form extension how will the form extension understand to whom to send the email after clicking the button of the HTML field within the userlist? When the visitor will fill in the form extension, the uid=[user_id] will have no meaning to the form extension, correct?

P.S. Maybe if adding this
if ( ( ! file_exists( JPATH_SITE . '/libraries/CBLib/CBLib/Core/CBLib.php' ) ) || ( ! file_exists( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' ) ) ) {
	echo 'CB not installed'; return;
}

include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' );
cbimport( 'cb.html' );
to the "Before Form" part of the component could help the process somehow?

Please Log in to join the conversation.

2 years 3 months ago #327904 by galanopd
Replied by galanopd on topic Email form
So far I can call the form extension from the HTML with the following
index.php?option=com_breezingforms&amp;ff_form=39&amp;ff_page=1&amp;view=emailuser&amp;uid=[user_id]&amp;emailoptions=free

and Auto Actions JQuery
$("select").click(function() {
  var open = $(this).data("isopen");
  if(open) {
    window.location.href = $(this).val()
  }
  $(this).data("isopen", !open);
});

I will check if the specific user will receive the message after payment...

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.206 seconds

Facebook Twitter LinkedIn