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
- Encrypt User last name in wordpress for security reasons
- where can i find the login page in wordpress and add my header to it
- If a theme will undergo major changes would it be better to clone the parent instead of writting a child theme?
- How to add custom Author Info Box to blog posts “only” and NOT custom post templates
- Upload image without resizing but insert in post with resizing
- Bio comes up when the visitor clicks on a picture
- Adding images to anchors in the list created and fetched with wp_nav_menu
- Unable to write error_log output… but only from a certain function
- Displaying Child Page’s Information
- Expressions and str_replace
- How to create a new blog in wordpress?
- How to find and replace (or add) specific word in a specific category?
- In wordpress customizer api adding div wrap to control
- How to create 2 preview button in a post?
- Multiple Owl Carousels on the same page with navigation problem
- Create single{custom}.php with data in table out of wp_posts
- permalink of word press in htacess
- Show comments based on user role in front end
- How to implement custom Javascript to my site
- generate a static copy of the website footer html
- Multi-site customization
- Move text from the side of image to below image [closed]
- WordPress Inline Style missing
- How do i edit text that is not in the customization menu
- How do I enable the text editer in my WordPress theme? [closed]
- Style Radio Buttons inside Edit Page (Custom Fields)
- Need to over ride a !important from the index file
- how to hard link to the posts page?
- Creating WordPress staging environment software
- How to add H1 Tag on Homepage?
- Overwrite user role
- Pull A Single Post Prior To Running wp_query
- Confusing problem with displaying message recipient metadata
- Trouble getting started in wordpress – my experience isn’t in wordpress.
- Responsive menu not expanding in footer
- issue with saving custom metaboxes fields
- Accountless password generation
- Getting a jQuery library to work in WordPress & Avada
- Creating a Treeview Listing of a Directory
- Changing ‘Add to cart’ button text and relink for some specific products [closed]
- adding a custom time class to in theme twenty sixteen
- Adding separate CSS files for separate pages with functions.php
- UPDATED: Save a custom_field value when automatically creating a post using wp_insert_post
- after checked the checkbox in backend, dont show social link on frontend
- Best way to sort posts with different types by distance
- WooCommerce – Adding custom HTML to specific product pages
- Best way to move a site to a subfolder for testing purposes?
- Page Permalinks: Custom URLs
- How do I move my sites to a child theme without loosing customisation?
- Wonderflux Framework Static Homepage
- How to send email with wp_mail() with from email taken from contact form instead of the host?
- Add commentmeta custom field to every published comment with SQL
- Query 1 custom post type, each day, alphabetically
- Highlight specific user with custom field value
- Displaying all Custom fields on post except some
- Change the default WordPress image on the dashboard login to a custom image [duplicate]
- Can I check who updated the static front page on WordPress and the time it was done
- Removing comma from ‘entry-date’ in Twenty-Sixteen theme
- Admin menu disable new/delete page
- WordPress Install – “end of script output before headers” when running simple php script
- Show different pages on site depending on user choice
- Is there a way to limit multi upload in media upload box?
- Ordering a specific post type
- Having a forum in a subfolder
- call get_header() function from different theme
- Use another theme template in my theme
- How to echo custom styles in css format?
- Error in establishing a database connection in wordpress?
- Accept HTML in custom function