I have been trying to figure this out for 2 weeks to no avail.
Each user on my site has a page, and I want to add a form where guests can send the user an email. I want to use Chronforms instead of Joomla contact form for obvious reasons... so much better.
I am using Joomla 3.1
URL Structure is: mydomain.com/username1, mydomain.com/username2, etc.
I saw the post on here http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=21710, but that did not seem to work. Maybe due to it being from 2011. I get error: You must provide at least one recipient email address. The form works fine if I set Static To value
Dynamic To is set to a hidden box field ptm_mail
This is the code I run OnSuccess (inside CheckCaptcha):
NOTE: I have id set to 921 just for testing to see if it can pull that user's email address. Figuring out how to get the real user id for the page is the other issue.
Appreciate your help! Thanks:)
Each user on my site has a page, and I want to add a form where guests can send the user an email. I want to use Chronforms instead of Joomla contact form for obvious reasons... so much better.
I am using Joomla 3.1
URL Structure is: mydomain.com/username1, mydomain.com/username2, etc.
I saw the post on here http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=21710, but that did not seem to work. Maybe due to it being from 2011. I get error: You must provide at least one recipient email address. The form works fine if I set Static To value
Dynamic To is set to a hidden box field ptm_mail
This is the code I run OnSuccess (inside CheckCaptcha):
<?php
$db =& JFactory::getDBO();
$query = "
SELECT `email`
FROM `#__users`
WHERE `id` = '921' ;
";
$db->setQuery($query);
$email = $db->loadResult();
JRequest::setVar('ptm_email', $email);
?>
NOTE: I have id set to 921 just for testing to see if it can pull that user's email address. Figuring out how to get the real user id for the page is the other issue.
Appreciate your help! Thanks:)
Hi candyb,
The first thing is to move your code out of the Check Captcha On Success event, just put it in a Custom Code action *after* the Check Captcha action.
Second is that there is a much simpler way of getting a User Email:
Third - see the example above is that ChronoForms v4 uses the $form->data array for form data so setting a value with JRequest doesn't make it usable (it used to work in CFv3).
Bob
The first thing is to move your code out of the Check Captcha On Success event, just put it in a Custom Code action *after* the Check Captcha action.
Second is that there is a much simpler way of getting a User Email:
<?php
$user =& JFactory::getUser(192);
$form->data['user_email'] = $user->email;
?>
Third - see the example above is that ChronoForms v4 uses the $form->data array for form data so setting a value with JRequest doesn't make it usable (it used to work in CFv3).
Bob
Oh Greyhead, THANK YOU! You have no idea how stumped I have been on this. You are awesome ๐
Now, the final part... any ideas how I can retrieve a user id from a page with format mydomain.com/username1
I have too many already to change it to query strings in the URL
Now, the final part... any ideas how I can retrieve a user id from a page with format mydomain.com/username1
I have too many already to change it to query strings in the URL
Hi Candy,
I'm not sure but try this to see if it helps diagnose.
Bob
I'm not sure but try this to see if it helps diagnose.
<?php
$url = JFactory::getURI();
$url_query = $url->getQuery();
echo'<div>$url_query: '.print_r($url_query, true).'</div>';
?>
That should print out the url query string and may show you the id info you need.Bob
Heyyy Greyhead! That was super helpful for me to test with๐ I think I have found a solution. I am able to use this line to get the menu id.
Now, if I just add an email field to the menu table, I can use that menu id to get the Send TO email. How would I query the database to pull data from the menu table?
$itemid = JRequest::getVar('Itemid');
Now, if I just add an email field to the menu table, I can use that menu id to get the Send TO email. How would I query the database to pull data from the menu table?
Sooooo so close. I put the email address in the Note field of the menu item. This is the code I have tried, but it is not picking it up. Err: You must provide at least one recipient email address.
<?php
$itemid = JRequest::getVar('Itemid');
$app = & JFactory::getApplication();
$menu = $app->getMenu($itemid);
$form->data['ptm_email'] =$menu->note;
?>
Hi candyb,
This looks OK. The Custom Code action with this code needs to be *before* the Email action.
Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.
Bob
This looks OK. The Custom Code action with this code needs to be *before* the Email action.
Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.
Bob
Hi again,
I haven't changed the order of the events in some time now. I think it is something with my code. Again, I'm using Joomla 3.1.
I haven't changed the order of the events in some time now. I think it is something with my code. Again, I'm using Joomla 3.1.
Hi candyb,
Bob
Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.
Bob
Hi Again,
Here's the results. Looks like the ptm_email field is populating from the code.
Here's the results. Looks like the ptm_email field is populating from the code.
Data Array:
Array
(
[chronoform] => ReferralApp-PT
[event] => submit
[fname] => John
[lname] => Doe
[city] => Somecity
[state] => CA
[email] => myemail@address.com
[phone] => 222-222-2222
[income_desired] => 300to500
[computer_skill_level] => Novice
[req_met] => Yes
[appt_date] =>
[opt_in] => 1
[ptm_hidden] =>
[chrono_verification] => QFn8x
[input_submit_12] => Submit
[ptm_email] =>
[6e874cd373386c17de92563343899d3e] => 1
)
Validation Errors:
Array
(
)
Debug Data
Core Captcha
Passed the core captcha check!
email
2
Result An email has been SENT successfully from (John)myemail@address.com to
Body
{}
First Name John
Last Name Doe
City Somecity
State CA
Email Address myemail@address.com
Phone Number 222-222-2222
How much do you desire to make weekly? * 300to500
Computer Knowledge/Skill Level Novice
To be considered, you must be 18yrs or older and have a computer, internet access and a phone. Do you meet these requirements? Yes
Best time(s) to contact you
Yes! Please add me to your mailing list for information on more opportunities 1
Hidden #28 {ptm_hidden}
Your data entered is completely confidential. We will never share or sell your information.
Enter the code QFn8x
PTM Email {ptm_email}
Submitted by 70.168.142.19
Attachments array ( )
redirect_user
redirect_user_target_url: http://www.powertogetwealth.net/application-success
Redirect URL (click to continue):
http://www.powertogetwealth.net/application-success
This topic is locked and no more replies can be posted.