Hi,
I would like to store user email in a session to pass it on to another page.
I have added the below code in the toolset custom code.
session_start();
$_SESSION['email']= 'user_email';
But it is not working. we got 'user_email' on the second page instead of the email value. I have added 'wpcf-' also before the field name but still, the value doesn't retrived.
Hello and thank you for contacting Toolset support.
Well, first of all, you need the user ID. If you are looking for the current user ID, you can get it with:
$user_id = get_current_user_id();
https://developer.wordpress.org/reference/functions/get_current_user_id/
Then you can get the user's email with the following code:
$user_info = get_userdata( $user_id );
$user_email = $user_info->user_email;
Please note that this is a general PHP/WordPress development question. It has nothing to do with Toolset and is therefore considered custom code. Custom code is out of the scope of this support forum. Consider hiring a developer or seeking support in a general support forum such as StackExchange or StackOverflow.
Thank you the code worked with the session. My issue is resolved now.