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 validation and error handling when saving custom fields?
- Validating Custom Meta Box Values & Required Fields
- Is there a way to set default custom fields when creating a post?
- Automatically delete inactive users after 2 months
- Is it safe to store a user setting you don’t want the user to ever modify as a user option?
- Add custom objects/entities to WordPress
- Can I count the number of users matching a value in a multiple value key?
- Save custom user meta on registration
- Adding another state (spam, reject, approve) to wordpress comments?
- Custom user avatar in the WordPress users listing
- User Profile / Add Custom Fields
- Edit Custom Database Tables in WordPress
- Filter results with custom field values and dropdown
- Meta keywords and descriptions plugin for manually editing meta for each page/post
- Making a configurable field translatable
- Is there a way to do multiple ordering on a multiple meta_query?
- Check before publishing, if already exist post with current custom field value
- How to customize default wordpress editor?
- generate unique number when registering a user
- How to update serialized data in the user meta data
- Custom Fields Bulk Edit
- Custom Page Template [closed]
- How to make custom comment fields required and message field not required
- Problem in custom meta boxes
- Extra User Profile Field Upload File / Image
- How to show custom field’s value under post/page title in wp-admin
- Multiplile values checkbox or select in custom meta box
- ajax delete value from custom field array
- Extra filed under “About the user” user profile
- How do I read the value of a custom field of the page?
- Upload files programmatically to users
- how to save multiple custom fields for a post in one go?
- Displaying additional User Contact Information
- get_post_meta in sitewide tags plugin fails to return value for custom fields
- Community and User Generated Content Website: Have been thinking about Drupal but leaning on WordPress heavily
- Best way to add custom / magic / flutter fields into RSS feed
- Unique User Account Number + Displayed Via Shortcode
- Separate table or usermeta
- Insert attachment ID in custom field from media uploader
- meta_query for a string inside a meta field containing a comma-separated list
- How to update custom user meta field in wp?
- 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?
- Delete all custom fields at once?
- Add More Fields to Users Pages (Admin Panel)
- Register rest field for specific user
- Buddypress Add unserialized Profile Fields in Members Loop [closed]
- ACF: How to get the full field name (meta_key) by a field key?
- How do I create a column in Users list and display user data from custom registration field
- 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
- Better Method for Multiple Meta Boxes
- Custom Fields – Taller editing area
- Front-end editing with custom fields?
- Displaying a checkbox array from advanced custom field
- WP 3.1 meta_query for multiple custom field values
- How to make condition, based on custom fields value?
- How to select posts from multiple categories and metavalues?
- Sort custom field by post
- Send email with custom fields after new draft is saved or new post published
- How to add upload video option in wordpress for user?
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- Customizing user data
- How do i add custom fields to my themes template file?
- Linking Custom Fields to Database Records
- How to save the date/time of last update of an extra user profile field?
- Custom tables or custom fields?
- Post selector as Custom 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 user info in a hovercard [closed]
- Customizing WP user profile with custom fields
- Iterate through users and display users meta info at front-page
- How to remove custom fields from the selector?