Welcome to the third and last part of the Gravity Forms Front End Login / Register / Edit account series.
Part 3Â – creating a simple edit account page
Unlike previously the form we’re going to create will be slightly different. First we need to output some data on the form, which will use Gravity Forms dynamic population. This will be bound to the currently logged in user for which we’ll load the data.
Let’s go ahead and create it. We need the following fields:
- EmailÂ (with the email CSS class assigned, and dynamic population variable set to email)
- Old PasswordÂ (with the old-passÂ CSS class assigned)
- NewÂ PasswordÂ (with the new-passÂ CSS class assigned)
- Repeat PasswordÂ (with the repeat-pass CSS class assigned)
- First Name (with the fname CSS class assigned, and dynamic population variable set to fname)
This form will let us change the associated email address, the password (for which we’ll need to provide a valid current password – safety precaution) and change our First Name.
Gform validation hooks
With all the fields filled we need to validate them before submitting the form. In our case this only applies to the old password, since all other fields need not be validate.
It’s worth nothing the comments added to the functions. We’re using a simple trick here – we’re assigning field validation to a specific form field and then comparing it’s value with a different form – which has a specific CSS class assigned to it!
Gform pre submission hook
GfromÂ field value hooks
Now, we need to make sure, that the fields actually list the data provided by the user. Since we’re accessing a predefined values, there are already functions for doing so. Let’s make usage of the global variable $current_user.
Latest posts by RafaĹ Gicgier (see all)
- WP Doin Recognized among Top Web Developers in Poland - 29 October 2019
- WordPress application development ACF & Gravity Forms - 3 August 2019
- OptiPic.io – How and why to optimize the image on the site? - 8 April 2019