A WordPress plugin that automatically initializes default values for Advanced Custom Fields (ACF) on existing posts and users.
When you add new ACF fields with default values to existing content, WordPress typically only applies these defaults to new posts/users created after the field was added. This plugin solves that problem by automatically applying default values to existing content that doesn't have a value for the field.
- π Automatic Default Value Application: Applies default values to existing posts/users when fields are saved
- βοΈ Field-Level Control: Enable/disable default value initialization per field
- π― Selective Processing: Only processes content that doesn't already have a value for the field
- π§ Manual Processing: Admin interface button for manual initialization
- π Multiple Post Types: Works with posts, pages, custom post types, and users
- π‘οΈ Safe Processing: Only updates empty fields, preserves existing data
- π¨ Clean Admin UI: Seamless integration with ACF field settings
- WordPress: 6.4 or higher
- PHP: 8.1 or higher
- ACF: Advanced Custom Fields (free or Pro version)
composer require mituu/acf-default-value-initializer- Download the plugin
- Upload to
/wp-content/plugins/acf-default-value-initializer/ - Activate through the WordPress admin
- Go to Custom Fields > Field Groups in your WordPress admin
- Edit any field group
- For each field you want to initialize defaults:
- Open the field settings
- Enable the "Initialize Default Values" checkbox
- Set your desired default value for the field
- Save the field group
The plugin supports default value initialization for:
- Text, Textarea, Number, Email, URL, Password
- Select, Checkbox, Radio, Button Group, True/False
- Date Picker, Date Time Picker, Time Picker, Color Picker
- Range, WYSIWYG, oEmbed
- User, Post Object, Page Link, Relationship, Taxonomy
- Image, File, Gallery
If you need to manually trigger default value initialization:
- Edit a field group in the ACF admin
- Look for the "π Initialize Default Values" button
- Click the button to manually process all existing content for this field group
When you save a field group with fields that have "Initialize Default Values" enabled:
- The plugin identifies all posts/users that match the field group's location rules
- For each field with initialization enabled, it checks if the post/user has a value
- If no value exists, it applies the field's default value
- Existing values are never overwritten
Field Group Save β Check Enabled Fields β Find Target Content β Apply Defaults
acf-default-value-initializer/
βββ acf-default-value-initializer.php # Main plugin file
βββ composer.json # Composer configuration
βββ assets/js/ # JavaScript files
β βββ field-settings.js # Admin UI enhancements
βββ src/ # PHP classes
βββ Plugin.php # Main plugin class
βββ Hooks.php # WordPress hooks
βββ FieldSettings.php # ACF field settings
βββ DefaultValueProcessor.php # Core processing logic
Plugin: Main plugin initialization and coordinationHooks: WordPress action/filter hooks managementFieldSettings: ACF field settings modificationsDefaultValueProcessor: Core logic for applying default values
The plugin uses these WordPress hooks:
acf/save_post- Triggers default value processingacf/render_field_settings- Adds the initialization checkboxwp_ajax_acf_dvi_process_field_group- Handles manual processing
Each ACF field can be individually configured:
// Field setting added by the plugin
'init_default_values' => 1 // Enable default value initializationThe plugin respects ACF location rules, so default values are only applied to content that matches the field group's location conditions.
# Clone the repository
git clone https://github.com/mituu-rs/acf-default-value-initializer.git
# Install dependencies (if using Composer)
composer install- PHP 8.1+ with strict types
- PSR-4 autoloading
- WordPress coding standards
- Comprehensive error handling
- Initial release
- Automatic default value initialization
- Field-level control settings
- Manual processing interface
- Support for all major ACF field types
For issues, feature requests, or contributions:
This project is licensed under the GPL v2 or later - see the LICENSE for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request