Here is some code that reads the highest number from the user meta table and then adds +1 to that number. This saves that number for each newly registered user. The code is triggered via the action hook "user_register".
add_action( 'user_register', 'assignuserid');
function assignuserid($user_id) {
global $wpdb;
$latestid=$wpdb->get_var("SELECT meta_value from $wpdb->usermeta where meta_key='memnumber' order by meta_value DESC limit 1;");
update_user_meta( $user_id, 'memnumber', $latestid+1 );
}
Note: If the “pay-” is fixed, it does not need to be part of the code that stores the value, only part of the output. i.e:
echo "Your userid: PAY-"+$userid.
Related Posts:
- generate unique number when registering a user
- Adding extra info via GET while registeration in wordpress
- Many users with strange names register, but don’t leave comments. Should I be afraid?
- Can I create front-end editable user profile pages with WordPress? How do I do it?
- Unique User Account Number + Displayed Via Shortcode
- How to pass external variables to the wp_new_user_notification_email filter?
- Add custom user profile field to default WordPress MultiSite registration form
- What’s wrong with Customizing new user notification email by add_filter?
- Function to allow “Anyone can register”?
- Create membership number for existing/new users
- I want to submit multiple users if checkbox is checked
- How Can I Move Data From Form 1 To Form 2
- Auto login from custom registration form
- Diffrent User registration form for doctor and patient
- Add Field to WordPress Register Form
- Undefined variable: user_id in get_user_meta
- Custom login and registration forms
- custom user meta query
- Custom Register Link on Backend Form
- Hook before user is created and make some custom validation
- How to change the login page without a plugin and not only customizing logo and text around the form?
- Gender based user avatar
- How to display all post from the same current usermeta
- Custom user fields validation on registration
- Changing starting number of User ID
- Custom options – register, defaults and delete empty fields (Settings API)
- add unique code required to register
- User registration add user ID?
- How to get value from wp_usermeta table in database?
- Redirect all pages to the custom login page except for the registration page
- Problems with WP 6.1.1 and the get_user_meta() function
- Where are Additional CSS files stored
- What Is The Use Of map_meta_cap Filter?
- Localization: I want the backend: english and frontend in defined language
- How to get current_cat in navbar, in single post
- wordpress custom walker for thumbnails with custom menu
- Adding an email column to a Custom Post Types Admin Screen?
- WordPress audio player has two different styles
- Allow Users to Set Password During Registration
- WordPress 3.1 removing ‘category’ from the slug
- Why does WordPress 3.0.4 keep deleting the contents of the .htaccess file?
- Intercept invalid email during lost_password
- How To Get User Data in Callback Function for pre_user_nicename?
- Hide upload image fields for the different media upload popups
- Custom Taxonomy Archive not displaying entries
- Displaying a Welcome Message to a Woocommerce User
- Creating Search Engine Friendly URL’s with Word Press
- Add Div to Comment Form
- Extend Screen Options
- How to add “Read More…” link in twentytwenty
- How to remove the search fields in Twentytwelve
- Understrap child theme JS not working in custom-javascript.js file
- Adding code to child’s theme css and php cannot override certain elements
- Resizing of a header/div in a website through css in wordpress [closed]
- Login/Logout Session Sharing – Multiple WordPress Installations
- Hide text if not homepage
- Is there a way to override require_once of the main theme on the child theme?
- How to format text of site subtitle
- Lost password and back to blog in same line
- Best Practice for Displaying Categorized Posts on Front Page
- WordPress broken after domain name change
- How to create “custom page types” with different custom fields in them?
- How to Restore Deleted Post Not in Trash
- How to Escape Custom Meta Data And Prefix Custom Meta ID
- New User Save Filter
- How To Style Links in Content Area With Tag Automatically?
- Display content of metabox if filled in
- Is it possible to integrate a custom login feature with wordpress?
- User Custom Dashboard
- Exclude current post but keep the same posts-per_page amount
- WordPress Command Question
- getting a 404 page for all pages except home. possibly permalinks
- Add custom border across footer widget area
- How to make conditional statement in WpBakery (formarly Visual Composer)
- Display all subterms of a custom taxonomy filtered by parent terms
- Adding shortcode to product short description
- Display Custom Taxonomy Name As A Shortcode
- Latest update broke my custom login CSS
- Removing fields and buttons from admin dashboard?
- How to fix custom add menu page preventing media library from loading
- Unhook a function within a class in the child theme
- How to serve an already coded html page in a WP page, to assign a simpler url
- Change the template of my Blog entries
- User WordPress menu in custom page
- Saving an array of values (file urls) to update_user_meta()?
- Custom display for homepage, tag and author pages
- Class .current-menu-item in custom menu Walker
- Add several fields from different tables to post, fields per post are in same row of table
- WP_Customize_Image_Control and selecting from library?
- How to cdv from a custom CMS to WP
- Get a different size of Image thumbnail while working with custom metabox
- Custom search by several options send on form not works
- Pagination is not working on custom query
- Issue with WordPress native theme customizer function and jquery ui tabs
- Complete Custom Style Part of Site
- add custom css on all page exept of one
- removing extra mobile menu from the header
- Admin new order email customization
- Add line break for menu items
- How do I get the URL section to show use a different domain in the WordPress Admin?