Here is how I would do it:
function save_extra_user_profile_fields( $user_id ) {
if (!isset($_POST['address']) || empty($_POST['address'])) {
// this field was not set or was empty
// do your action
wp_redirect( home_url() ); // or profile page
exit;
} else {
// field was set and contains a value
// do your action
update_user_meta( $user_id, 'address', $_POST['address'] );
wp_redirect( home_url() ); // or whatever success page
exit;
}
}
Related Posts:
- Drop down list in user profile page
- Add custom fields to the user profile
- How do I update user email from frontend input field?
- How can i add user display name drop down menu in frontend?
- Require confirmation of current user’s email before updating database and before send_email_change_email
- Difference between update_user_meta and update_user_option
- Make display name unique
- get_user_meta() doesn’t include user email?
- Replacing the WordPress password validation
- Where the Nickname is being used in WordPress
- How to display custom user meta from registration in backend?
- Allowing an email as the username?
- Grouping users under parent user
- How to create a template for a custom URI associated with the user
- How to order users alphabetically by their last name?
- How to create a public profile for authors/contributors/users?
- How we can get the user id by its display_name
- WP_User_Query with combined meta query – not working?
- How to use hyperdb to separate and share a user dataset between wordpress installs?
- LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- Upload gravatar in WP profile?
- How to add follow functionality to multi-author wordpress site?
- Search multiple meta keys at once
- Where to Store Custom User Fields
- Querying Email Addresses for a List of Users with Same Last Name?
- Front end user meta options for users
- ACF Upload Image in front-end with custom form
- Extra User Profile Field Upload File / Image
- How to add country drop down menu to the user profile?
- Custom style on profile options page
- stop login if user_status equal zero
- How to add local users to wordpress without email password?
- Does wp_delete_user() remove all user content?
- WP User Query fails when searching meta queries and search columns
- How can i create an array user meta?
- Disable user profile editing for one user
- Updating user meta
- how to make a profile entry read only except for site managers [closed]
- WordPress User Profile Upload – If page is saved file reset
- Are User Levels Still Currently Used?
- How to add a user profile page to frontend?
- WPML Default Language User Meta [closed]
- Display users in order by an “order” custom meta field
- Search Users base on meta_value & meta_key
- User Meta Data in a Sortable Table
- get_user_meta an ID for multiple functions
- Column Sorting Code on users.php
- Profile page for user roles
- Creating user without username and password
- Is this code true or not
- User description only displayed for logged user
- The Simple and Correct Way to Add User Meta
- Create a “user log”
- Assign random (and unique) user meta upon registration
- How to display text if profile fields are not filled?
- What is correct way to change user’s email?
- Display the line breaks in user bio without using html
- how to set default update_user_meta values wordpress
- How to hide user profile fields based on the role of the viewed user?
- Get user by meta key – WP multi site
- Update a user profile via frontend
- Cannot Update user meta in custom field
- Can I Create a Second Admin Level User Role?
- How to make current user’s avatar + display name link to their profile?
- Give users alternative/second avatar that is rectangle sized
- redirect user to their profile after log in
- Adding fields to the “Add New User” but the form data not saved into DB
- New User Save Filter
- Assigning multiple or additional capabilities to specific users or how to create additional roles like bbpress roles?
- What does “link” refer to when you delete a user?
- delete_user_meta from a foreach results page
- How to display all user profile info in myaccount page wordpress
- WordPress 5.8 – Hide or Remove personal fields from admin Profile page
- Reading additional fields in PMPro
- Can I add a unique code for each user based on the location?
- How to display extra fields for user
- I need a link that directs the user that is logged to his profile
- Getting user data via ajax
- Safely changing UserID’s, re-using deleted UserID’s and automatically using deleted userID’s instead of an increment
- How to make custom user profile page public?
- meta_query orderby sort multiple keys
- How to update user meta from php file?
- In admin manage users page, how can I stop users with certain privileges from editing users with other privileges?
- Get meta key with value for user
- user and usermeta table not found
- UserMeta Changes Meta Value for Post ID
- Restrict Access to the User Profile
- How do I change the user via SQL?
- Add method for tracking who referred new users
- Username has been exposed
- Separate Profiles for Users
- Designing a member area on my site
- Display all existing members
- Modify Profile Biographical Info Field
- Problem with update_user_meta() meta_value
- Add custom input field in new user page
- WordPress – Security Question at Login from User’s Meta Data
- MySQL query to list users who never signed in
- Can we get user profile page using user_id in the URL?