PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Populate and Hide Name and Email for Logged in Users

  1. I have a form that has two required fields for Name and Email at the top of the form.

    How can I populate these fields with a user's data and hide them for logged in users?

    This is a public form that anyone can use, so I need those fields to be visible for non-logged in users but it is redundant to ask logged in users for this information.

    Thanks!

    Posted 11 years ago on Tuesday August 16, 2011 | Permalink
  2. Currently there is no way to hide fields for logged in users. But you could pre-populate them with the users data. For the Name Field in order to do this you'd have to use the Simple format which uses one field.

    You would then go to the Advanced tab when editing these fields and use the insert variable drop down to insert the merge tag for the Users Email or the User Display Name. See this screenshot: http://i.imgur.com/05gDj.png

    The merge tag {user} can also be used to access any user meta information using it's name/key. You would use {user:key} with the key being the name of the user meta you want to display.

    Posted 11 years ago on Tuesday August 16, 2011 | Permalink
  3. You could use the built-in WordPress body class of "logged-in" to target the id's for name and email. Then you could hide them with CSS display:none. The logged-in body class would not be present if the user is not logged in, so the fields would not be hidden.

    You would still do as Carl suggests and pre-populate the form fields. They would just be empty when the user is not logged in (and visible) and would be filled (and not visible) when the user is logged in.

    Hiding the fields with CSS is not secure: they're still present in the source of the page. But it did not sound like you wanted security, you just wanted to eliminate redundant inputs for logged in users.

    Posted 11 years ago on Wednesday August 17, 2011 | Permalink