Just add a meta record that tracks the state of the username-changing actions:
$user = wp_get_current_user();
$did_one_change = get_user_meta($user->ID, 'changed_username', true);
if($did_one_change !== false)
wp_die('You already changed your user name once!');
wp_update_user(array(
'ID' => $user->ID,
'first_name' => $_POST['first_name'],
'last_name' => $_POST['last_name'],
));
// here add a meta entry that suggests the user has changed their name once
update_user_meta($user->ID, 'changed_username', 1);
Related Posts:
- “You do not have sufficient permissions to access this page” upon accessing my newly created plugin page
- Show username only if logged in in a else no directly name
- How can I configure Docker for developing and deploying a custom theme?
- Add screen options to custom admin pages
- Add self-closing shortcode button to TinyMCE in WP 4.6
- Completely remove WP_Admin_Bar for specific user roles
- WordPress and PHP Sessions – Security and Performance
- WordPress Hook for user register
- What is the difference between using global $current_screen and get_current_screen()?
- How to make repeated component/block in Gutenberg
- Must-use plugins autoloader: How to use get_plugins() correctly?
- Changing upload directory for plugin uploads only
- Upload file to remote storage
- How do I conditionally enqueue script for CPT single post type with plugin?
- wp_localize_script $handle
- Help adding image upload functionality to widget
- Why won’t register_setting() create a setting?
- How do I only load js on the post-new.php and post.php pages in admin?
- Plugin vs Settings load order (woocommerce dependency)
- Screenshot are not showing up on plugin page
- How to not let a user with a new role edit users that have administrator role?
- Modifying values with add_action to be sent to db
- Callback function is being called twice
- async code or cron job?
- Configuring WordPress Auth Cookie Expiration
- How to display a message about updates in the plugin list
- How to save WP widget instances and options
- Loading jQuery and jQuery plugin script files correctly [duplicate]
- How to use radio buttons in WordPress plugin options using register settings?
- WordPress not working on localhost
- manage_posts_custom_column, showing serial number using increment in loop
- Custom delete option button in plugin settings
- SQL query for custom taxonomy slugs
- Sub Menu content is being duplicated
- how to append custom metabox field with the ACF custom fields id in wordpress development
- $_FILES empty on created_{taxonomy} and create_{taxonomy} yet is is not on edit_{taxonomy}
- What should happen when a WordPress Plugin is activated across the network (Network Wide Activation)
- Send push when new post is published in a certain category
- Storing data in wordpress database from ajax call from different website
- Prevent invalid or empty values from being saved to the database and retain the form field values upon error
- Hide shortcodes “code” when using the “editor” the same as wordpress do with “gallery”
- wp E-commerce featured product plugin with muliple option?
- Adding fields to category manager. Does a method exist to get the link to the category edit screen?
- How to test a WordPress plugin in real time
- How to Trigger WP CRON at Local Timestamp?
- Problem with saving checkbox values with WordPress Widget API
- Force download file from plugin (change output http headers)
- Distributing Frontend Assets with Plugins
- How to get all product in the woo-commerce? [closed]
- Wp-admin Custom User Management
- Check user’s role and store in variable
- What’s the hook for filtering every texts of site?
- Hook add_attachment error
- Undefined variable’s error when expected to have passed the content of variable [closed]
- Shortcode conflicts
- How can I add rewrite rules to a class-based plugin?
- hook update_option/updated_option empty $old_value and $value
- Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
- How to add a panel/box/widget/are/screen to the right side of edit post/page confusion
- Sharing Variables between scheduled events
- Issue with plugin sub menu and pages
- How can I programmatically change a MySql variable (foreign_keys_check)?
- Problem with display data from get_option
- Screenshots on plugin page taken old [closed]
- Should I put my plugin javascript inline?
- Get Posts by IDs (optionally)
- Can / should a widget plugin define its own Widget Area?
- How do I duplicate a single post, with all its properties, and save it as a different post?
- Why doesn’t my Table get created?
- Extract Information from post content (using regex?)
- Using jQuery prepend() with file include
- want to show CMB2 metabox on woocommerce product data tab
- Customise Grouped Product display in Woocommerce with custom column
- How to get the `comment_post_ID`?
- Can someone explain what’s the use of parse request function in WordPress?
- Add parameters to 3rd party callback function
- Ajax action has 200 status but response of No response data available for this request
- How does update method in Widget class saves $instance array from Select tag?
- Google Web Core Vitals – management, how to in wordpress and advice
- WooCommerce – Stop assigning order numbers
- How can I pass WP_Query results to a plugin?
- Hiding the WordPress login and password fields from login page
- Adding customs fields on each product on the cart
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- Buddypress: adding a new tab direct user to their author page
- Why would one specify multiple arguments when using get_previous_posts_link() which takes only one parameter?
- WC_Geolocation not found inside plugin
- Set widget icon in Customizer?
- How to customize the size of Featured Images or Post Thumbnails in WordPress?
- I have a plugin where in I have to change the title of the page dynamically by sending parameter to the_title filter
- Hook for plugin to show content for certain urls
- Why does unzip_file always return true but nothing happens?
- Let user override plugin CSS
- How can I map a specific URL pattern to a plugin for processing
- What happens when you create/edit a menu
- Add_menu_page and saving settings
- Updating Style From WP Options Setting Page
- What method would I use to show an image in between X amount of posts on category archive? [duplicate]
- Plugin – Proper way to handle 404 pages?
- Is wordpress plugin development active? [closed]