Creating a matching site using WordPress [HivePress] Adding first and last name fields to the user registration form

At HanamiWEB Online School,

●Ask questions in real-time in the virtual study room!

●Ask as many questions as you want via chat!

●E-learning materials that you can learn as much as you want, 24 hours a day!

All included for just 2,500 yen/month!

We will explain the code introduced in the HivePress code recipe.

Code snippet

Add first and last name fields to user registration form

[ 'required' => true, '_order' => 1, ], 'last_name' => [ 'required' => true, '_order' => 2, ], ] ); return $form; }, 100 ); add_action( 'hivepress/v1/models/user/register', function( $user_id, $values ) { if ( isset( $values['first_name'] ) ) { update_user_meta( $user_id, 'first_name', $values['first_name'] ); } if ( isset( $values['last_name'] ) ) { update_user_meta( $user_id, 'last_name', $values['last_name'] ); } }, 10, 2 );

Implementation results

After adding the code, a first and last name field was added to the user registration form.

Add to function.php

The code is added to function.php.

  • Create a child theme and add it to function.php
  • Added using the code snippets plugin

Please edit function.php in one of two ways.

This blog post explains the prerequisites you need to know before editing function.php!

Leave the reskilling of your website to us!

Since 2019, we have been sharing skills related to WordPress and websites. We have accumulated case studies and know-how, and are good at quickly and accurately solving problems. If you have any concerns about your website, please feel free to contact us via our official LINE account!

↑Click to open the official LINE page

Latest Articles

(Solved) Emails sent from WordPress to Gmail are not being sent [Lollipop]
Explaining package (ticket) settings for the WordPress reservation system Amelia
Zoom Integration Server-to-Server OAuth Settings
WordPress Security Enhancement Plugin All in one WP Security ~ iframe Protection feature explained
WP Rocket - WordPress Caching Plugin
en_USEnglish