[Solved] Form Builder: Send form to logged in FEU

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
jomoweb
Forum Members
Forum Members
Posts: 49
Joined: Wed Jan 31, 2007 9:27 pm

[Solved] Form Builder: Send form to logged in FEU

Post by jomoweb »

I have built a form with Formbuilder that is bound to front end users. I would like to email the submission to the logged in user, and that is not a field option. If I could even retrieve their email address (feu username), I could make a javascript solution. I can only seem to get properties and not the email/username from FEU. I have tried all of these, but I have a feeling that variable may be private and cannot be accessed.

{$ccuser->property('name')}
{$ccuser->property('username')}
{$ccuser->property('email')}

Any ideas on how I can retrieve the email/username of the logged in feu, or perhaps send them an email without them having to enter it again in a secondary form field?


CMS Install Information
CMS Version 1.11.4
FormBuilder 0.7.3
CustomContent 1.8.3
FormBrowser 0.4.2
FrontEndUsers 1.21.2
Last edited by jomoweb on Tue Apr 30, 2013 12:20 am, edited 2 times in total.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Form Builder: Send form to logged in FEU

Post by Wishbone »

According to CustomContent help, it's $ccuser->property(), not $ccuser->properties()

Can you explain what you mean by "a form that's bound to front end users" ??
jomoweb
Forum Members
Forum Members
Posts: 49
Joined: Wed Jan 31, 2007 9:27 pm

Re: Form Builder: Send form to logged in FEU

Post by jomoweb »

Thanks Wishbone, I did use property, that was a typo when I was making my post, and I've updated it. But thank you for mentioning custom content help. I feel like a rookie for mot checking it before my post!

This is how you get the email of the logged in FEU:
{$ccuser->username()}

There is a form option called "Form Browser with FEU Binding." It will store the form results to the FEU to access with form browser. I don't really think that it would affect my issue here either way, but I thought I would mention that I was using it.

This would make it very easy if the *Email results to set addresses accepted smarty vars for email, but it does not.

For anyone else attempting this, I used these steps:

1. Create hidden fields for email recipient, subject line, from name, from email address.
2. Fill in values with what you want.
3. Make sure process smarty tags is checked on the advanced tab of the email recipient field.
4. Input {$ccuser->username()} as that field value.
5. Add a new field: *Email results based on front end field
6. Choose the hidden fields you just created to build the email.

There maybe a better way, but this worked for my situation!
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: [Solved] Form Builder: Send form to logged in FEU

Post by Wishbone »

The only issue is that in Chrome, I can click on the form, "Inspect Element" and change the hidden fields to a different values, and create a way to spam.

I prefer to set it to call a UDT, then have the UDT call CMSMailer to send it to the current user.

Also, are you using CustomContent to make it so that only logged users can use the form? If so, that doesn't restrict people from direcly POSTing to that form, unless you check for it with an if statement around {content}
jomoweb
Forum Members
Forum Members
Posts: 49
Joined: Wed Jan 31, 2007 9:27 pm

Re: [Solved] Form Builder: Send form to logged in FEU

Post by jomoweb »

Thank you for pointing out those security concerns. The form is pw protected to fronte end users, but I don't have much security other than that. The form is about 20 pages long, so it would take quite an effort to spam.

But these are great ideas I will work on integrating.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: [Solved] Form Builder: Send form to logged in FEU

Post by calguy1000 »

The form is about 20 pages long
Holy $#!t are you asking people for their tax returns? seriously man, no online form should be 20 pages long... 3 or 4 is PUSHING IT!.

Nobody can be expected to enter 20 pages in 15 or so minutes (the typical length of a php session). not to mention you will tend to run into technical limits like POST max size etc, etc.

I think you better be re-thinking some stuff.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
jomoweb
Forum Members
Forum Members
Posts: 49
Joined: Wed Jan 31, 2007 9:27 pm

Re: [Solved] Form Builder: Send form to logged in FEU

Post by jomoweb »

It is an online quiz/learning module with about 3 multiple choice questions per page.

I couldn't find any plugins or other OS software that really fit the bill.

Form builder is actually working like a champ for the project with a couple little workarounds.
jomoweb
Forum Members
Forum Members
Posts: 49
Joined: Wed Jan 31, 2007 9:27 pm

Re: [Solved] Form Builder: Send form to logged in FEU

Post by jomoweb »

Wishbone,

Do you have a sample UDT you would like to share for the application you were talking about? I'd be very interested in applying your solution to my form.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: [Solved] Form Builder: Send form to logged in FEU

Post by Wishbone »

I set the form to call a UDT (instead of sending mail) .. In the UDT, you can do a var_dump($params), to see what the fields are.

Then do something like:

Code: Select all

# Get user id. Reject if not logged in.

$ccuser = $smarty->get_template_vars('ccuser');
$userid = $ccuser->loggedin();
if ($userid <= 0) {
  return;
}

# Get Message

$message = $params['your_message']; # <-- Use your field name

# Get email address

$feu = cmsms()->GetModuleInstance('FrontEndUsers');
$email = $feu->GetEmail($userid);

# Send the mail

$cmsmailer = cmsms()->GetModuleInstance('CMSMailer');
$cmsmailer->AddAddress($email);
$cmsmailer->SetSubject('This is my subject');
$cmsmailer->SetBody($message);
$cmsmailer->IsHTML(true);
$cmsmailer->Send();
This ensures that you're sending to the logged in user, not depending on hidden fields, which are easily modified.

This is a hacked version of a UDT I wrote yesterday.. Not tested in this exact configuration. Good idea to comment out the $cmsmailer->Send(), and print out the various variables until you're sure that you have what you think you have.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: [Solved] Form Builder: Send form to logged in FEU

Post by Wishbone »

There's many other tricks that can be done as well. If you want the email body to be configurable and you don't want the site admin to edit PHP, you can set some smarty variables in the UDT, and call in a GCB, where the message can be configured how you want, with the smarty variables where ever the user wants it.

I have a tutorial on this....

http://www.i-do-this.com/blog/35/Sendin ... EU-Invites

It's a bit outdated.. You have to replace all calls to $gcms with cmsms() to get it to work.
jomoweb
Forum Members
Forum Members
Posts: 49
Joined: Wed Jan 31, 2007 9:27 pm

Re: [Solved] Form Builder: Send form to logged in FEU

Post by jomoweb »

Thanks! I have read your blogs before and appreciate the work you have posted on i-do-this. It is all very helpful.
Locked

Return to “Modules/Add-Ons”