How do you know that the checkbox value is not being saved? I’m guessing that it is saved to the database; however, in your code, you do not have any method of setting the “checked” attribute for the checkbox to “checked”. As such, you will not see the boxed checked.
You’ll need something like the following to achieve this effect.
<?php $checked = ( get_the_author_meta( 'test2', $user->ID ) == 'some-value' ) ? ' checked="checked" : ''; ?>
<input type="checkbox" name="test2" id="test2" value="some-value" class="regular-text"<?php echo $checked; ?> /><br />
Just make sure to change “some-value” to the value that you want.
Related Posts:
- How to get users by a custom field / by user meta data?
- How do you add a custom option to user data?
- Show User Their Password
- Adding Properties to User Profile and Displaying in List
- How can I sort get_users() by any value (last_name, user defined fields and more)
- get_user_meta Short Profile Section
- WordPress User Profile Upload – If page is saved file reset
- WP_User_Query pulling ACF to loop
- query usermeta from custom field
- custom avatar removal
- Passing args to WP_User_Query am I using meta correctly?
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- check for duplicate user meta data before updating
- Custom Field Repeating When Using foreach
- Front-End User Profile
- Get emails from users by custom field SQL
- Delete user meta but only if found in array
- Extend WP_User_Query or WP_User to return all custom fields?
- Is it possible in WordPress
- Echo text if field under user_meta is empty with get_users()
- Semi-Private Comments + page comments -> is it possible?
- How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?
- Add custom objects/entities to WordPress
- Custom user avatar in the WordPress users listing
- User Profile / Add Custom Fields
- Making a configurable field translatable
- Is there a way to do multiple ordering on a multiple meta_query?
- How to update serialized data in the user meta data
- Custom Fields Bulk Edit
- Custom Page Template [closed]
- Extra User Profile Field Upload File / Image
- Extra filed under “About the user” user profile
- Upload files programmatically to users
- how to save multiple custom fields for a post in one go?
- Best way to add custom / magic / flutter fields into RSS feed
- Separate table or usermeta
- Insert attachment ID in custom field from media uploader
- Redirect users based on custom field
- Custom User Profile Fields
- Does wp_delete_user() remove all user content?
- How do you create dynamic customised sections in WordPress?
- Add More Fields to Users Pages (Admin Panel)
- Register rest field for specific user
- ACF: How to get the full field name (meta_key) by a field key?
- Want to Add Custom Fields for Uploading video to WordPress Users from front end
- How to save multiple options from a dropdown in user profile
- How to show a gloabl message on a user profile page (in back end)?
- Users Select inside custom metabox
- Custom Fields – Taller editing area
- Front-end editing with custom fields?
- How to make condition, based on custom fields value?
- How to select posts from multiple categories and metavalues?
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- Linking Custom Fields to Database Records
- How to save the date/time of last update of an extra user profile field?
- I need a “Choose from existing content” popin
- For homepage images (for small business website), is it better to use custom fields or post_thumbnail?
- Show image if author meta (profile fields) exists outside loop
- How can I hide custom field from users used for caching response from external api?
- How to query an out put value?
- Check & remove special characters in a field?
- Let’s Create Custom Field Template Documentation
- how to make a custom field readonly or disabled by user role?
- frontend submit post jQuery clone row won’t save
- award points to a user each time they update their cpt post
- Get text from user and display it on page
- Custom Fields Question
- New User Save Filter
- Custom meta boxes not saving
- How to get all custom fields with some prefix in key?
- Searching with Multiple (Parallel) Criteria on Custom Fields?
- Make separate text boxes for separate WordPress Custom Fields
- How to parse a huge list of users using a CRON function?
- Adding re-type email and check it if the email match
- Counting post fields
- Approach to creating a site with this structure
- Display Additional Info
- Populate custom checkout fields with data from previous orders
- Auto populate a user custom field from another user custom field
- User query – getting values for custom meta keys/fields
- How to get data from user meta custom fields created with acf-pro plugin?
- Get all user meta_keys and then group users by matching values
- Autofill advanced custom field with user data
- Link fields in User Admin list
- Confusing problem with displaying message recipient metadata
- update_user_meta(): invisible data storage
- When post is updated, custom metadata in text area field is overwritten
- Custom Meta Boxes and Fields for WordPress: Change directory upload based on user-edit page
- Extend WP_Customize_Control with Multiple Field Control
- custom field functionality
- How to add an option to admin to add image that could be used as header?
- Show or hide lang=”ur” in main element
- How can I create more “create attachment” custom field – any idea?
- Adding thumbnails for non-image attachments
- Add image custom attribute [closed]
- how to add radio field on user meta on function.php?
- file upload user profile
- Problem display
- Create Unique and Customized User ID for Website Members in WordPress
- Add fields to edit in custom widget