WP Automation
Event-driven automation for WordPress. Define custom actions triggered by hooks (post save, user actions, etc.) to dynamically update user roles, meta fields, and more. No coding required for simple automations.
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/cerebrocodes/wp-automation/archive/refs/heads/main.zipReadme
README.md markdown
WP Automation
Event-driven automation for WordPress – attach actions (role changes, meta updates, logging, etc.) to any WordPress hook without writing code for each scenario.
Features
- 🔌 Hook-based triggers – listen to any WordPress action (e.g.,
save_post,publish_post,user_register). - 🎛️ Flexible conditions – control when an action runs (e.g., only on new posts, only for specific post types).
- ⚙️ Reusable actions – generic action classes that accept parameters (add/remove roles, update meta, send logs, etc.).
- 🧩 Theme integration – automations can live in your theme (child/parent) for version control and portability.
- 📁 Directory‑based – drop PHP config files into
automations/and action classes intoactions/. - 🔒 Secure – uses WordPress capabilities and nonces where applicable.
Quick Start
-
Activate the plugin – upload to
/wp-content/plugins/wp-automation/and activate. -
Create an automation – add a PHP file in
wp-automation/automations/returning an array:<?php return [ 'event' => 'save_post_book', 'conditions' => [ function($post_id, $post, $update) { return !$update && 'publish' === $post->post_status; } ], 'action' => ['WPA_Action_AddUserRole', 'run'], 'parameters' => [ 'role_to_add' => 'book_author' ] ]; Create the action class – extend the plugin by adding a class in wp-automation/actions/: php class WPA_Action_AddUserRole { public static function run($post_id, $post, $update, $params) { $user = new WP_User($post->post_author); $user->add_role($params['role_to_add'] ?? 'subscriber'); } } Done – publish a book post and the author will get the book_author role.
Directory Structure (Plugin + Theme)
Plugin core: wp-automation/{actions,automations,includes}/
Theme overrides (child/parent): wp-automation/{actions,automations}/
Requirements
WordPress 5.0+
PHP 7.4+
Advanced Usage
Use the wpa_automation_directories filter to add custom directories.
Use 'transition_post_status' with conditions for granular control.
Combine multiple automations for complex workflows.
Contributing
Pull requests and issues are welcome. Please follow WordPress coding standards.
License
GPLv2