function store_session($values){ if( $values['form_id'] == 13){ $session_src = 'unknown';< if(isset($_SESSION['source'])){ $session_src = $_SESSION['source']; } $values['item_meta'][182] = $session_src; } return $values; } add_filter('frm_pre_create_entry', 'store_session');Do you have an idea why this fails ?
Where is your start_session() located? How are you populating $_SESSION['source']? When I test for the values of $_SESSION using your code in my development environment, $_SESSION is NULL. $_SESSION is not enabled unless you start and manage the $_SESSION yourself.
WordPress has "abstract class WP_Session_Tokens" you can extend to use for your own $_SESSION variables. https://developer.wordpress.org/reference/classes/wp_session_tokens/
You can also create your own $_SESSION without extending the WordPress class. https://www.php.net/manual/en/reserved.variables.session.php
Hi Victor and thanks for your answer.
Sorry i wasn’t torough in my descritption, but to summarize and answer your questions :
- the session and it’s variables are declared in the WP’s header.php
- the error is a typo when i copy/pasted my function (i cleaned up some irrelevant code regarding the problem). The function runs without problem on my website.
Thanks for the reference to wp_session_tokens i think that will do the trick 🙂
Please login or Register to submit your answer