-2

When a user enters my site, the first page will ask them for their name. I want to make a tailored experience for each user.

How would I save this text input to a PHP variable so that I can then display their name on any page?

For example, if the user clicks contact us, the page will address them by the name they entered initially.

Edit: I am using contact form 7 and want to use the users answers to generate a URL. Maybe there is a better solution?

0

The best way to have tailored experience is to make people to sign in to the site. Once they are logged in, you can store whatever information in the DB and retrieve it when needed.

If you do not want to ask for more than a name, you can generate a wordpress user for them with some dummy email and password and set the authentication cookies to have long expiry time, but this might not be ideal, very much depends on what is exactly that you want to do.

You can try to use cookies, but that will work only for a relatively shorter time period and might cause problems when you will want to server cached pages.

  • That's perfect. But lets say I wanted a user to fill in a contact form i.e – RootAccess Aug 19 '18 at 1:43
  • not sure why does it make any difference – Mark Kaplun Aug 19 '18 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.