For unique 4 digit number, the following code work fine
function unique_number($length=10) {
$string = '';
// You can define your own characters here.
$characters = "0123456789";
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters)-1)];
}
return $string;
}
print unique_number(4);
Every plugin has extended capability to change the default value of field or form. You should need to know how this work.
I am giving you the example for ACF custom fields.
//for acf
function my_acf_load_field( $field ) {
$rand = unique_number(4);
$field['default_value'] = $rand;
return $field;
}
add_filter('acf/load_field/name=your_field_name', 'my_acf_load_field');
Related Posts:
- OAuth Plugin Produces Error With Yahoo
- Count posts by type including drafts and pending posts
- Link for ‘Show all Events Categories’ [closed]
- Plugin for single language localisation [closed]
- Display Custom Field Value on Admin Page Column
- How to remove/hide Yoast’s “SEO” tab in admin panel?
- Is there an easy way to download all plugins from the repo?
- Integrating WP E-commerce plugin into custom theme
- Is it possible to send blog posts via email to subscribers?
- Posting from WordPress to Facebook [closed]
- Is Timthumb still broken? What security measures should be taken?
- Is there any plugin which can paste a common content to my every post?
- Combining several CSS files into one for optimization
- What is the WordPress approach to custom data?
- The XXX plugin has been deactivated due to an error: The plugin does not have a valid header
- Which filter/action should I use to serve content for “virtual” files
- Is it a standard to have an empty `index.php` in root of Plugin? [duplicate]
- WordPress Fatal Errors [closed]
- Plugin showing error
- Sell access to form [closed]
- How to rewrite URL and get the values?
- Problem after updating plugins
- BuddyPress: filter member based on Xprofile Field
- WordPress plugin require_once unexpected
- How to access the WordPress DB from a plugin file
- What is the best way to hook a rewrite function for certain php code when plugins are updated?
- WordPress.com Like Button
- Undefined index: ratings_score …/wp-postratings.php on line 994
- Does anyone know what’s the plugin for this Comment Section?
- What is the most effecient way of enqueuing scripts based on the current plugins template?
- Automatic recurring payment using YITH subscription and Dokan Stripe
- Author & date removal
- Code for unique user visit count on every page WordPress
- How to overwrite the category template in a plugin
- post title not changing at post page
- Circumvent WP CLI Command
- show wc_add notices on particular page in woo commerce custom plugin development
- Custom Formdata matching with user table
- upload multiple images using wp_handle_upload
- How to Disable Right Click on wordpress Dashboard(Admin Area)
- https rewrite not working for All in one security Brute force > rename login url
- How to align a text left side while keeping vertically centered? [closed]
- Code Snippets plugin by Shea
- Customize plugin templates
- admin-ajax.php returning 0
- How do I restrict a second admin certain access?
- Why my multisite is this slow? (stats inside)
- htaccess question and plugins.php
- wordpress plugin page error
- jQuery to show icon after .hide
- WordPress connecting posts
- Different Urls for mobile and desktop homepages
- Insert Plugin on a custom page
- WordPress Theme/Plugin Install (about FTP Connection)
- Can’t enable/disable plugins in non bulk mode
- Power Menus plugin destroys menu after adding new item
- Update page (update-core.php) & Plugins page (plugins.php) revert to homepage
- trying to create simple plugin to filter categories from all authors
- RSS Feed has no Items (Possible Plugins Conflict)
- conditional tags for the output of a plugin
- Change post permalink to external URL from custom field
- how to debug shipping module / class
- cPanel login from WordPress
- single.php fires more than once after clicking on any post to view with different post id each time
- Can’t insert files in other inputs
- Can’t get custom user meta to show in header
- How can I add the custom taxonomy categories to the posts and pages?
- WordPress Plugin: Where should I put my cookies for cURL?
- WP Members additional fields on user profile [closed]
- Save post to category with gravity forms (post_data) [closed]
- WordPress Customer Reviews Error: Line 239?
- How to create a page template using custom plugin
- WordPress 3,5 and Jquery version
- WooCommerce, different prices based on location [closed]
- Creating a press page for our project
- How do I edit a plugin’s core properly?
- Change Woothemes admin url
- wordpress illegal string offset ‘parameter’ error
- How to convert hits from Top 10 plugin to WordPress Popular Posts? [closed]
- WP can’t send newsletters
- Defer parsing of JavaScript [duplicate]
- Gutenberg Block to Select Category Term
- Update post meta Rest Api
- cURL External API request displays content above other content on page
- A way to upload old html pages with all its assets via WordPress admin and to add a fixed menu on top of those (a la Wayback Machine)
- How to give specific class name to category in wordpress with code snippets
- Problem moving to category posts page
- admin_enqueue_scripts using hook_suffix vs GET page
- Wp Plugins Update
- i need to resive data external api and show user
- Getting table to format properly in RSS feed emails
- Getting table to format properly in RSS feed emails
- How to fix a Wordfence scan that doesn’t finish?
- WordPress.Security.NonceVerification.Recommended
- My Revolution Slider suddenly appears two times after updating
- BBPress Customization with Custom Plugin
- Order Posts Using Taxonomy Term Facetwp [closed]
- Is there potential plugin incompatibility if theme has no header.php and footer.php?
- Is SSL connection of plugins default?
- Custom Gutenberg blocks not showing in WP editor