Wordpress Admin User Profile

I’m building a WordPress website for a local business and I want to add a custom field to the user profile page for clients to input their physical address. But, I don’t want this field to be publicly visible on the user’s profile page. Is there a way to create a custom field that is only visible in the WordPress admin dashboard and not on the frontend of the site? If so, how can I do it?

Thanks in advance!

You have two options:

i)code it yourself (for developers)
ii) Use a plugin (for beginners).
In the first option, you add the field with code and hide it on the public profile page using functions like add_action. Alternatively, if that looks complicated for you, I suggest that you use a plugin instead.
They are easy to find and install from the WordPress plugins directory or through your WordPress dashboard. Plugins such as Advanced Custom Fields or User Meta Manager will help you create this field by following some clicks.

Both methods keep client addresses secure in the admin area, hidden from public view.

It’s quite straightforward to add a custom field to the user profile page in the WordPress admin dashboard. However, I’m curious as to why you think this would affect the frontend. By default, WordPress does not display user profile fields on the public-facing site. Could you provide more details on what you are trying to achieve and any specific concerns you have regarding frontend visibility?

Here is a somewhat niave implementation for you to try.
Add the following to your functions.php file.

function my_custom_user_profile_fields( $user ) {
	?>
		<h3>Additional Information</h3>
			<div class="user-custom-field">
			<label for="physical_address">Physical Address</label>
			<input type="text" name="physical_address" id="physical_address" value="<?php echo esc_attr( get_the_author_meta( 'physical_address', $user->ID ) ); ?>" class="regular-text" />
			<p class="description">Please enter your physical address.</p>
		</div>
	<?php
	}
add_action( 'show_user_profile', 'my_custom_user_profile_fields' );
add_action( 'edit_user_profile', 'my_custom_user_profile_fields' );

function my_save_custom_user_profile_fields( $user_id ) {
	if ( ! current_user_can( 'edit_user', $user_id ) ) {
		return false;
	}
	update_user_meta( $user_id, 'physical_address', $_POST['physical_address'] );
}
add_action( 'personal_options_update', 'my_save_custom_user_profile_fields' );
add_action( 'edit_user_profile_update', 'my_save_custom_user_profile_fields' );

LMK if that works for you, then we could look at refining it to suit your needs.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.