How to Use Advanced Custom Fields to Register Users in WordPress
By default, WordPress offers a simple registration form with fields like username and email. But what if you want to collect more user information—like job title, phone number, or company name—during registration?
With Advanced Custom Fields (ACF), you can easily extend the default user registration system by adding custom fields. In this tutorial, we’ll show you how to:
- Add custom user fields using ACF
- Display a custom registration form on the front end
- Save ACF data to the user profile upon registration
This method is great for building custom membership sites, community platforms, or internal portals.
Step 1: Install the Required Plugins
You’ll need:
- Advanced Custom Fields (ACF) – for creating custom fields
- ACF Extended (optional) – adds more field options
- A code snippet plugin (like Code Snippets) or access to your theme’s
functions.php
file
Step 2: Create Custom Fields for User Registration
- Go to Custom Fields > Add New.
- Name your field group, e.g., “User Registration Fields”.
- Under Location, set:
- User Form > is equal to > All (or just “Add/Edit” if preferred).
- Add the custom fields you want, such as:
- Text Field: “Phone Number”
- Select: “User Role”
- Date Picker: “Date of Birth”
- Publish the field group.
These fields will now appear on the User Profile page in the admin area, but we’ll also show how to use them in a front-end registration form.
Step 3: Create a Front-End User Registration Form
WordPress doesn’t provide a front-end registration form by default, so we’ll build one manually using HTML and PHP.
Example Registration Form Template:
phpCopiarEditar<form method="post">
<input type="text" name="username" placeholder="Username" required>
<input type="email" name="email" placeholder="Email" required>
<input type="password" name="password" placeholder="Password" required>
<input type="text" name="phone" placeholder="Phone Number">
<input type="text" name="company" placeholder="Company Name">
<?php wp_nonce_field('custom_user_register', 'custom_user_register_nonce'); ?>
<input type="submit" name="custom_user_register_submit" value="Register">
</form>
You can place this code in a custom page template or use the Shortcode API.
Step 4: Process the Form and Register the User
Add the following PHP code to functions.php
or a custom plugin:
phpCopiarEditarfunction handle_custom_user_registration() {
if (isset($_POST['custom_user_register_submit'])) {
if (!isset($_POST['custom_user_register_nonce']) || !wp_verify_nonce($_POST['custom_user_register_nonce'], 'custom_user_register')) {
return;
}
$username = sanitize_user($_POST['username']);
$email = sanitize_email($_POST['email']);
$password = $_POST['password'];
$phone = sanitize_text_field($_POST['phone']);
$company = sanitize_text_field($_POST['company']);
$errors = new WP_Error();
if (username_exists($username)) {
$errors->add('username', 'Username already exists.');
}
if (email_exists($email)) {
$errors->add('email', 'Email already registered.');
}
if (empty($errors->errors)) {
$user_id = wp_create_user($username, $password, $email);
if (!is_wp_error($user_id)) {
// Save ACF fields
update_field('phone', $phone, 'user_' . $user_id);
update_field('company', $company, 'user_' . $user_id);
// Redirect or show success
wp_redirect(home_url('/registration-success'));
exit;
}
}
}
}
add_action('init', 'handle_custom_user_registration');
Replace
'phone'
and'company'
with the field names (keys) from your ACF field group.
Step 5: Display ACF User Data in the Dashboard or Front End
To display the saved user data, use:
phpCopiarEditar$user_id = get_current_user_id();
$phone = get_field('phone', 'user_' . $user_id);
$company = get_field('company', 'user_' . $user_id);
You can output this anywhere on the front end—such as a profile page, dashboard, or custom user panel.
Optional: Use ACF Frontend Form Plugin (Pro)
If you want to avoid writing custom PHP, you can use the ACF Frontend for Elementor or ACF Frontend Form Pro plugins. These tools let you:
- Build registration forms visually
- Connect them to ACF user fields
- Manage user data without code
Conclusion
With Advanced Custom Fields, you can take full control of the WordPress user registration process, allowing you to:
- Capture rich user data with custom fields
- Build custom registration forms for any use case
- Store and display user data throughout your website
This approach is ideal for membership sites, intranets, event registrations, and more. With a bit of custom code, or the right plugins, you can offer a seamless user experience that matches your brand and needs.
For more advanced WordPress tutorials, keep following KnowbaseWP.