Hire Now!
Whether you’re looking to launch your brand, showcase your portfolio, or open an online store, we’re here to bring your ideas to life.
Understanding the Hook: show_user_profile
and edit_user_profile
These hooks allow you to add custom fields to the user profile page in the admin area.
Add fields to the profile page and save them using the personal_options_update
and edit_user_profile_update
actions.
Code Example
function add_custom_user_profile_fields($user) {
?>
<h3>Extra Information</h3>
<table class="form-table">
<tr>
<th><label for="twitter">Twitter Handle</label></th>
<td>
<input type="text" name="twitter" id="twitter" value="<?php echo esc_attr(get_user_meta($user->ID, 'twitter', true)); ?>" />
</td>
</tr>
</table>
<?php
}
add_action('show_user_profile', 'add_custom_user_profile_fields');
add_action('edit_user_profile', 'add_custom_user_profile_fields');
function save_custom_user_profile_fields($user_id) {
if (!current_user_can('edit_user', $user_id)) {
return false;
}
update_user_meta($user_id, 'twitter', sanitize_text_field($_POST['twitter']));
}
add_action('personal_options_update', 'save_custom_user_profile_fields');
add_action('edit_user_profile_update', 'save_custom_user_profile_fields');
Website security is a top priority for WordPress site owners. From brute force attacks to malware, threats are everyw…
Affiliate marketing is a proven way to monetize your website and drive additional revenue streams. WordPress affilia…
Integrating secure and efficient payment gateways is essential for any e-commerce site. WordPress payment gateway pl…
WooCommerce is one of the most popular platforms for building online stores, but its functionality can be significan…
No results available
ResetDiscussion
Get the latest news about our updates and discounts
Copyright © 2024 - CollectWP
Powered by DeoPixel with love & passion 💪
Content Harmony: On-Site Data