Hi,
I'd like to know a little bit more about the "session to data" function, I've been reading the last paragraph of this FAQ which describes what I'm looking for, but I still can't figure it out:
https://www.chronoengine.com/faqs/63-cfv4/cfv4-working-with-form-data/2697-how-can-i-use-the-form-data.html
Basically I´ve got 50+ forms, all of these forms have a hidden field called "source". I use this field to identify the source of the lead, facebook, google, etc. and it will be passed on to our CRM.
All the hidden "source" fields are empty, so at the moment I populate them as following:
www.mydomain.com/landingpage-google/?source=google
And this works fine, when the landing page doesn't have any links, when it does.. I mark them with "?source=google", but when they reach to the next page.. this parameter will be lost obviously.
So I'd like to use the "Session to data" option to, when a certain form is loaded, it will store a value of "source" for a certain amount of time which will populate the hidden field of all other forms..
Am I looking in the right direction by using the "Data to session"?
Thanks in advance.
I'd like to know a little bit more about the "session to data" function, I've been reading the last paragraph of this FAQ which describes what I'm looking for, but I still can't figure it out:
https://www.chronoengine.com/faqs/63-cfv4/cfv4-working-with-form-data/2697-how-can-i-use-the-form-data.html
Basically I´ve got 50+ forms, all of these forms have a hidden field called "source". I use this field to identify the source of the lead, facebook, google, etc. and it will be passed on to our CRM.
All the hidden "source" fields are empty, so at the moment I populate them as following:
www.mydomain.com/landingpage-google/?source=google
And this works fine, when the landing page doesn't have any links, when it does.. I mark them with "?source=google", but when they reach to the next page.. this parameter will be lost obviously.
So I'd like to use the "Session to data" option to, when a certain form is loaded, it will store a value of "source" for a certain amount of time which will populate the hidden field of all other forms..
Am I looking in the right direction by using the "Data to session"?
Thanks in advance.
Hello jorgve,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
My form data isn't saving to the database correctly
My CFv5 form data isn't saving to the database correctly
How do I save form data to a database table?
How to load record data from a database table into your form
P.S: I'm just an automated service😉
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
My form data isn't saving to the database correctly
My CFv5 form data isn't saving to the database correctly
How do I save form data to a database table?
How to load record data from a database table into your form
P.S: I'm just an automated service😉
Hi jorgve,
Joomla! has a User session that is kept open fro as long as the user is active on the site. Actually for a time after that set in your Global Configuration - it defaults to 15 minutes.
You can save data to the User session using the Data to Session actions - though they are designed to save all of the form data. It might be better to use a Custom Code action in the On Load event of your forms to save just the source value. This would need to be before the HTML (Render form) action.
Here's one way to code this - it gives priority to a new value of source over a saved one.
Bob
Joomla! has a User session that is kept open fro as long as the user is active on the site. Actually for a time after that set in your Global Configuration - it defaults to 15 minutes.
You can save data to the User session using the Data to Session actions - though they are designed to save all of the form data. It might be better to use a Custom Code action in the On Load event of your forms to save just the source value. This would need to be before the HTML (Render form) action.
Here's one way to code this - it gives priority to a new value of source over a saved one.
<?php
$jsession = \JFactory::getSession();
$source = $jsession->get('source', '');
if ( !empty($form->data['source']) ) {
$source = $form->data['source'];
}
$jsession->set('source', $source);
$form->data['source'] = $source;
?>
Bob
Hi GreyHead,
Thanks for your reply, do you also know if there is a similar solution for Wordpress?
I see that maybe I posted this in the wrong topic, I'm sorry for that.
All the best,
Jorg
Thanks for your reply, do you also know if there is a similar solution for Wordpress?
I see that maybe I posted this in the wrong topic, I'm sorry for that.
All the best,
Jorg
Hi Jorg,
Not exactly the same - I'm not very familiar with CF in WordPress, but you could use code like this example I found.
Bob
Not exactly the same - I'm not very familiar with CF in WordPress, but you could use code like this example I found.
Bob
Thanks for your fast reply!
I've saw that example, but I can't really get it to work, since I don't have a lot of php knowledge.
I´ve put in the functions.php:
And in a Custom Code action in the On Load event:
But it isn't working..
Not really sure where and how to get the data using the code:
I've saw that example, but I can't really get it to work, since I don't have a lot of php knowledge.
I´ve put in the functions.php:
add_action('init', 'myStartSession', 1);
add_action('wp_logout', 'myEndSession');
add_action('wp_login', 'myEndSession');
function myStartSession() {
if(!session_id()) {
session_start();
}
}
function myEndSession() {
session_destroy ();
}
And in a Custom Code action in the On Load event:
$_SESSION['source'] = "source_test";
But it isn't working..
Not really sure where and how to get the data using the code:
if(isset($_SESSION['source'])) {
$value = $_SESSION['source'];
} else {
$value = '';
}
Hi jorgve,
Please try
Bob
Please try
<?php
if(isset($_SESSION['source'])) {
$form->data['value_name'] = $_SESSION['source'];
} else {
$form->data['value_name'] = '';
}
?>in a Custom Code action where you want to access the saved data.
Bob
Many thanks for the code GreyHead, but unfortunately it isn't working..
I didn't change de code in the functions.php (altough I did some variations which I found on other websites), and I've put in a Custom Code action in the On Load event:
When I enable the debugger, it just shows the field "source" empty, it doesn't give any error.
I don't know if I'm doing something wrong, or if you have any suggestion?
I didn't change de code in the functions.php (altough I did some variations which I found on other websites), and I've put in a Custom Code action in the On Load event:
<?php
$_SESSION['source'] = "source_test";
if(isset($_SESSION['source'])) {
$form->data['value_name'] = $_SESSION['source'];
} else {
$form->data['value_name'] = '';
}
?>
When I enable the debugger, it just shows the field "source" empty, it doesn't give any error.
I don't know if I'm doing something wrong, or if you have any suggestion?
This topic is locked and no more replies can be posted.
