Black Friday is live. Up to 52% off, our biggest discount ever.

Prices go up after the sale, so these numbers won’t come back.

Grab the deal →
wprigel logo
  • Home
  • Products
    • krom-automation-icon

      Krom Automation

      Build visual workflows that respond to signups, orders, forms, and posts- automatically. Free plugin, no monthly fees.
    • commandify-logo-pink

      Commandify- Best Command Palette Plugin for WordPress

      Navigate, search, and manage everything on your site with a simple keyboard-first workflow.
    • pollify plugin logo

      Pollify- Ultimate Poll Creator Plugin for WordPress

      Build interactive polls, surveys & voting experiences in WordPress with the best Gutenberg-native poll plugin.
  • Docs
  • Blog
  • Contact Us
  • Login
Pricing
  • How to Send a Custom Email When a WooCommerce Order Status Changes

    You can send a custom email when a WooCommerce order status changes in two ways: build a workflow on a visual canvas in about five minutes with no code, or register a custom WC_Email class using the woocommerce_order_status_changed hook. Neither approach requires touching your theme files or installing a bulky extension. This tutorial walks through both methods so you can choose the one that fits your setup.

    WooCommerce sends built-in emails for a handful of statuses like Processing, Completed and Refunded. The moment you add a custom status, such as “Ready for Pickup” or “Awaiting Inspection”, WooCommerce goes silent. That gap is where orders fall through and customers stop trusting your store.

    We tested both methods on WordPress 6.5 with WooCommerce 8.9. The no-code path takes roughly 5 minutes to configure. The PHP path takes 20 to 40 minutes if you have never written a WC_Email subclass before, but it gives you full template control and zero plugin dependencies.

    Which Method Should You Use?

    SituationBest methodApproximate setup time
    One or two statuses, non-developerVisual workflow builder5 minutes
    Multiple statuses with different logic per statusVisual workflow builder with branching15 to 30 minutes
    Full HTML template control, no plugin dependenciesPHP hook + WC_Email subclass20 to 40 minutes
    Send to admin AND customer with different contentVisual workflow builder (two actions)10 minutes
    Also need to tag CRM, update Sheets, or notify SlackVisual workflow builderAdds 2 minutes per extra action

    If you are running more than three custom statuses or need to chain additional actions after the email, the no-code path will save you hours of maintenance every time WooCommerce updates its email API. The PHP path is the right call when you need pixel-perfect HTML templates or cannot add another plugin.

    Method 1: No-Code Workflow Builder (Recommended for Most Stores)

    This method uses the free Krom Automation plugin from the WordPress.org plugin directory. The free version includes both WooCommerce triggers you need: Order Created and Order Completed. The Order Status Changed trigger, which fires on any transition you define, is included with no paywall.

    Step 1: Install the Plugin

    Go to Plugins > Add New in your WordPress admin. Search for “Krom Automation” and click Install, then Activate.

    You will see a new Krom Automation menu item in the sidebar. If you have not done this before, the installation guide covers the full process including server requirements.

    Step 2: Create a New Workflow

    Click Krom Automation > Workflows > Add New. You will land on the visual canvas, a drag-and-drop builder.

    You will see a blank Start node already placed. Give the workflow a name in the top-left field, something like “Ready for Pickup Email”.

    Step 3: Set the Trigger

    Click the Start node and choose Order Status Changed from the WooCommerce trigger group. You will see two dropdowns: From Status and To Status.

    Set From to “Processing” and To to your custom status, for example “Ready for Pickup”. If you want this email to fire regardless of the previous status, leave From set to “Any”.

    Setting “From Status” to Any is fine for most stores. Setting it to a specific status prevents the email firing when you manually correct a mis-entered status, which is a subtle but important distinction.

    Step 4: Add the Send Email Action

    Click the plus icon below the trigger node to add an action. Select Send Email from the Email group. You will see fields for To, Subject, and Body.

    • To: Enter {{order.billing_email}} to send to the customer. Enter a fixed address like orders@yourstore.com to notify your team. Add both in separate action nodes if you need both.
    • Subject: Something like “Your order #{{order.number}} is ready for pickup”.
    • Body: Plain text or HTML. Use merge tags to inject live order data. The full list of available merge tags is documented in the merge tags reference.

    Merge tags pull data directly from the order at the moment the trigger fires. {{order.total}}, {{order.billing_first_name}}, {{customer.email}} and {{order.line_items}} are the ones most stores use in order emails. Each tag resolves to the live value with no extra configuration.

    Step 5: Test Before Publishing

    Click the Simulate button in the top toolbar. The simulator runs the workflow against a real order ID you supply, showing you exactly what each action would do without sending any actual emails.

    This is a dry run with zero side effects. The simulator documentation explains how to read the output and spot misconfigured merge tags before they reach a real customer.

    Once the simulation looks right, toggle the workflow from Draft to Active and save. The next time an order moves to your target status, the email fires automatically in the background via Action Scheduler, so it does not slow down the status-change request.

    Step 6: Add Conditional Logic (Optional)

    If you want different email content depending on order value, shipping method or customer role, add a Condition node between the trigger and the action. Set the Yes path to your premium customer email and the No path to the standard one. The conditions and branching documentation covers every available operator.

    A workflow that sends different emails to wholesale and retail customers based on order total takes about eight minutes to build. Writing that logic in PHP takes significantly longer and breaks on every WooCommerce major version.

    Method 2: PHP Hook and WC_Email Subclass

    This path requires no plugin beyond WooCommerce itself. You will use the woocommerce_order_status_changed action hook and register a custom email class. WooCommerce’s own documentation on email configuration and the WordPress plugin hooks reference are worth bookmarking before you start.

    Step 1: Register the Custom Status

    If you have not already registered your custom status, add the following to your theme’s functions.php or a site-specific plugin. Using a site-specific plugin is safer because theme updates will not wipe your code.

    add_action( 'init', function() {
        register_post_status( 'wc-ready-pickup', array(
            'label'                     => 'Ready for Pickup',
            'public'                    => true,
            'exclude_from_search'       => false,
            'show_in_admin_all_list'    => true,
            'show_in_admin_status_list' => true,
            'label_count'               => _n_noop( 'Ready for Pickup (%s)', 'Ready for Pickup (%s)' ),
        ) );
    } );
    
    add_filter( 'wc_order_statuses', function( $statuses ) {
        $statuses['wc-ready-pickup'] = 'Ready for Pickup';
        return $statuses;
    } );
    

    Step 2: Create the WC_Email Subclass

    Create a file called class-wc-email-ready-pickup.php and place it in your plugin or a dedicated /includes/emails/ folder. The class must extend WC_Email.

    class WC_Email_Ready_Pickup extends WC_Email {
    
        public function __construct() {
            $this->id             = 'ready_pickup';
            $this->title          = 'Ready for Pickup';
            $this->description    = 'Sent when an order is marked Ready for Pickup.';
            $this->heading        = 'Your order is ready!';
            $this->subject        = 'Order #{order_number} is ready for pickup';
            $this->template_html  = 'emails/ready-pickup.php';
            $this->template_plain = 'emails/plain/ready-pickup.php';
            $this->template_base  = plugin_dir_path( __FILE__ ) . 'templates/';
            $this->placeholders   = array(
                '{order_number}' => '',
                '{order_date}'   => '',
            );
            parent::__construct();
        }
    
        public function trigger( $order_id, $order = false ) {
            if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
                $order = wc_get_order( $order_id );
            }
            if ( is_a( $order, 'WC_Order' ) ) {
                $this->object                         = $order;
                $this->recipient                      = $order->get_billing_email();
                $this->placeholders['{order_number}'] = $order->get_order_number();
                $this->placeholders['{order_date}']   = wc_format_datetime( $order->get_date_created() );
            }
            if ( $this->is_enabled() && $this->get_recipient() ) {
                $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
            }
        }
    
        public function get_content_html() {
            return wc_get_template_html( $this->template_html, array(
                'order'         => $this->object,
                'email_heading' => $this->get_heading(),
                'email'         => $this,
            ), '', $this->template_base );
        }
    
        public function get_content_plain() {
            return wc_get_template_html( $this->template_plain, array(
                'order'         => $this->object,
                'email_heading' => $this->get_heading(),
                'email'         => $this,
            ), '', $this->template_base );
        }
    }
    

    Step 3: Register the Email Class with WooCommerce

    WooCommerce collects all email classes via the woocommerce_email_classes filter. Add your class to the array so WooCommerce knows it exists and can display it in WooCommerce > Settings > Emails.

    add_filter( 'woocommerce_email_classes', function( $email_classes ) {
        require_once plugin_dir_path( __FILE__ ) . 'includes/emails/class-wc-email-ready-pickup.php';
        $email_classes['WC_Email_Ready_Pickup'] = new WC_Email_Ready_Pickup();
        return $email_classes;
    } );
    

    Step 4: Hook the Trigger to the Status Change

    Use the woocommerce_order_status_changed hook to call your email’s trigger() method. This hook fires after every status transition and passes the order ID, the old status slug and the new status slug.

    add_action( 'woocommerce_order_status_changed', function( $order_id, $old_status, $new_status ) {
        if ( 'ready-pickup' === $new_status ) {
            $email_class = WC()->mailer()->get_emails()['WC_Email_Ready_Pickup'];
            $email_class->trigger( $order_id );
        }
    }, 10, 3 );
    

    Step 5: Create the Email Templates

    WooCommerce expects HTML and plain-text template files. Create templates/emails/ready-pickup.php and templates/emails/plain/ready-pickup.php inside your plugin.

    Copy the structure from WooCommerce’s own woocommerce/templates/emails/customer-processing-order.php as a starting point. That keeps your email visually consistent with the rest of WooCommerce’s transactional email set.

    What the Guides Leave Out: Hidden Costs and Real Failure Modes

    Every tutorial shows you the happy path. Here is what breaks in production.

    • WP-Cron on low-traffic sites: The no-code workflow uses Action Scheduler, which relies on WP-Cron. If your store gets fewer than roughly 20 visits per hour overnight, emails scheduled during quiet periods may fire late by 30 to 90 minutes. Fix this by configuring a real server cron job to call wp-cron.php every five minutes. The WordPress developer docs on WP-Cron explain the setup.
    • PHP method breaks on major WooCommerce updates: WC_Email internals change between major versions. The get_content_html() method signature changed between WooCommerce 7 and 8. Budget 30 to 60 minutes of review time after each major WooCommerce update if you go the PHP route.
    • Sending to admin AND customer: WooCommerce’s built-in emails send to one recipient per class. For the PHP method, you need a second email class or a second wp_mail() call inside the same trigger. With the visual builder, you add a second Send Email action node pointing to your admin address. That takes about 90 seconds.
    • Custom statuses disappearing after plugin deactivation: If you used a third-party “custom order status” plugin to register the status and later deactivate it, all orders in that status lose their status label. The status slug stays in the database but WooCommerce cannot read it. Keep status registration in your own code, not in a plugin you might remove.
    • Emails landing in spam: Neither method fixes deliverability. If your server’s PHP mail() function is not authenticated, the email will likely land in spam regardless of content. Use an SMTP plugin or a transactional email service like Postmark or SendGrid. The WooCommerce email FAQ covers SMTP configuration options.

    Deliverability is not a WooCommerce problem. It is a mail server problem. Fixing the email trigger without fixing the sending infrastructure means perfectly written emails end up in spam folders, which is worse than no email at all.

    Going Further: What Else You Can Do on Order Status Change

    Once you have the email working, the same trigger can power additional actions in the same workflow. These are common extensions stores add after getting the basic email right.

    • Tag the customer in FluentCRM or ActiveCampaign when an order reaches a specific status, so follow-up sequences fire automatically.
    • Add a row to Google Sheets for every fulfilled order, giving the ops team a live fulfilment log without dashboard access.
    • Post a message to a Slack or Discord channel when a high-value order completes, so the team knows immediately.
    • Generate a unique coupon and email it to the customer after their first completed order. We covered this exact pattern in the guide on sending a coupon after a customer’s first WooCommerce order.
    • Change the customer’s WordPress user role after purchase, which is documented step by step in how to change a user role after a WooCommerce purchase.

    All of these actions sit on the same canvas as your email node. You are not building separate automations for each one. That matters for maintenance: one workflow to audit rather than five separate plugins each handling one piece of the same event.

    If your store uses WooCommerce Subscriptions, the same pattern applies to subscription events. The WooCommerce Subscriptions integration documentation lists the available triggers and action examples.

    Other Tools Worth Knowing About

    Pollify is wpRigel’s Gutenberg-native poll and survey plugin. Polls are built as real blocks inside the editor, so there are no shortcodes to paste and no separate interface to learn. If you collect post-purchase feedback on order confirmation pages, it integrates naturally with the block editor.

    Commandify is a command palette for the WordPress admin. Press Cmd or Ctrl plus K to search orders, products and customers, change order status, apply coupons or resend order emails, all without navigating through menus. It is the only WordPress command palette with real WooCommerce order management commands built in.

    Frequently Asked Questions

    Why isn’t WooCommerce sending an email when I change the order status manually?

    WooCommerce only sends emails for the statuses it knows about by default: Pending, Processing, On Hold, Completed, Cancelled, Refunded and Failed. Custom statuses get no email unless you explicitly configure one using either the PHP method above or a workflow tool. Manually changing a status in the admin does fire the woocommerce_order_status_changed hook, so the PHP method will work for manual changes as long as the hook is registered correctly.

    Can I send different email content for each custom order status?

    Yes. With the PHP approach, create one WC_Email subclass per status and register each separately.

    With the visual builder, create one workflow per status or use a single workflow with conditional branching on the “To Status” value. The branching approach keeps your workflow count low when you have four or more custom statuses.

    How do I send the order status change email to both the admin and the customer?

    In the PHP approach, add a second wp_mail() call inside the same trigger function, or create a second email class. In the visual builder, add two Send Email action nodes to the same workflow: one with {{order.billing_email}} as the recipient and one with your admin address. Both fire in the same workflow run.

    How do I resend a WooCommerce order status email manually?

    Go to the order edit screen in WooCommerce, scroll to the Order Actions meta box on the right, and select “Resend [email name]” from the dropdown. Click the arrow button to trigger it.

    If your custom email does not appear in that dropdown, the email class is not registered correctly with the woocommerce_email_classes filter. With the visual builder, you can manually trigger a workflow from the execution history panel by selecting the order and clicking Re-run.

    Do custom WooCommerce order status emails work with HPOS (High-Performance Order Storage)?

    Yes, as long as you use wc_get_order() to retrieve the order object rather than querying the wp_posts table directly. Both methods in this tutorial use wc_get_order(), so they are compatible with HPOS. WooCommerce’s official guidance on HPOS compatibility is in their developer documentation.

    Next Steps

    If you are starting from scratch and want the fastest path to a working custom order status email, install the free plugin from WordPress.org and follow Method 1. You will have a live workflow in under ten minutes with no code to maintain. If you need full template control or cannot add a plugin, Method 2 gives you everything WooCommerce exposes natively.

    Either way, fix your SMTP setup first. The best-configured email trigger in the world does nothing if the mail lands in spam.

    Try Krom Automation free on WordPress.org

    The wpRigel Team

    November 18, 2026
    Krom Automation, WooCommerce
  • How to Create a WooCommerce Coupon Automatically

    Creating a WooCommerce coupon automatically means connecting a trigger (a completed order, a registration, a date) to a coupon creation action without anyone clicking through the dashboard. This tutorial covers three approaches ordered by setup effort, so you can stop at whichever fits your stack.

    WooCommerce itself handles manual coupon creation well. The gap is in trigger-based, event-driven generation: issuing a unique code the moment a customer completes their first order, registers an account, or hits a spend threshold. That gap is what this tutorial fills.

    We tested all three methods on a fresh WordPress 6.5 install with WooCommerce 8.9 and PHP 8.2. The steps below reflect exactly what we saw on screen.

    What You Are Actually Building

    Before choosing a method, be clear on what “automatically” means in your case. The three common patterns are different problems with different solutions.

    • Event-triggered coupon: A unique code is created and emailed the moment a specific event fires. Example: order completed, registration, subscription renewal.
    • Scheduled batch generation: A cron job creates a set of unique codes on a timed schedule, ready for a campaign. Example: 500 loyalty codes generated every Monday.
    • Auto-apply via URL: No new coupon is created. An existing code is applied automatically when a customer clicks a link. Example: an email link that pre-fills checkout.

    The table below maps each pattern to the right approach so you do not spend an hour on a method that does not match your intent.

    What You Want Best Approach Requires Paid Tool?
    Unique code per customer on order complete Visual workflow automation Free tier available
    Coupon on new user registration Visual workflow automation Free tier available
    Scheduled bulk generation on a timed loop PHP hook + WP-Cron schedule No (code only)
    Auto-apply code from an email link URL parameter trick No (native WooCommerce)
    Coupon based on order total tier Conditional branching in a workflow Free tier available

    Method 1: Visual Workflow (No Code, Event-Triggered)

    This is the right starting point for most setups. You build a workflow on a drag-and-drop canvas, pick a WooCommerce trigger, add a “Create Coupon” action, and the plugin handles execution in the background every time the event fires.

    We used Krom Automation for this walkthrough. The free version includes both the Order Completed trigger and the Create Coupon action, so the full flow below costs nothing.

    Step 1: Install the Plugin

    Go to Plugins → Add New in your WordPress admin. Search for “Krom Automation” and click Install Now, then Activate.

    If you prefer, download it directly from the WordPress.org plugin directory. Full installation steps are in the installation documentation.

    Step 2: Create a New Workflow

    In your admin sidebar, go to Krom Automation → Workflows, then click Add New Workflow. You will see the visual canvas. Click the trigger node at the top of the canvas to open the trigger selector panel on the right.

    Step 3: Set the Trigger

    Scroll to the WooCommerce group and select Order Completed. This fires every time an order moves to the “Completed” status.

    If you want the coupon sent after payment rather than after fulfillment, select Order Created instead. The free triggers reference lists every available option with its exact fire condition.

    Step 4: Add the Create Coupon Action

    Click the plus icon below the trigger node to add an action. Select Create Coupon from the WooCommerce action group. The action panel opens on the right with these fields:

    • Coupon Code: Type a static prefix like “THANKYOU” or use a merge tag such as {{order_id}} to generate a unique code per order. Combining both, for example “THANKYOU-{{order_id}}”, gives you a readable but unique code every time.
    • Discount Type: Percentage, fixed cart, or fixed product.
    • Coupon Amount: The numeric value. For 15% off, enter 15.
    • Expiry Date: Leave blank for no expiry, or enter a fixed date. For a rolling expiry (30 days from now), use a delay node before a secondary action instead.
    • Usage Limit: Set to 1 to prevent forwarding. Leave blank for unlimited.

    A coupon without a usage limit of 1 is not a personalized reward. It is a discount code waiting to be posted on a deals forum.

    Step 5: Add a Send Email Action

    Click the plus icon below the Create Coupon node and add a Send Email action. In the email body, insert the coupon code using the merge tag you configured in Step 4. The merge tags documentation shows every available variable and the exact syntax.

    Set the recipient to the customer’s email using the {{customer_email}} merge tag so it sends to whoever placed the order, not a fixed address.

    Step 6: Enable and Test

    Toggle the workflow to Active using the switch at the top right of the canvas, then click Save. Use the workflow simulator to run a dry-run pass with a sample order. The simulator shows you exactly which nodes would fire and what values each merge tag would resolve to, with zero side effects on your live store.

    Place a real test order and mark it Complete. Check the customer’s inbox within a few seconds.

    If the email does not arrive, go to Krom Automation → Logs and look at the execution record for that run. The per-step audit trail shows exactly which action failed and why.

    Method 2: Coupon on New User Registration

    The trigger changes from Order Completed to User Registered. Everything else in the workflow is identical. This is one of the most common loyalty setups: a welcome discount the moment someone creates an account.

    In Step 3 above, select User Registered from the User trigger group instead of Order Completed. Use {{user_email}} in the email action to reach the new registrant. The coupon code can include {{user_id}} to keep it unique per account.

    If you want to combine both triggers, build two separate workflows rather than one complex one. That way each has its own execution log and can be paused independently. The workflow settings documentation covers the run-once-per-entity option, which prevents a customer from triggering the same welcome coupon twice if they somehow register twice.

    Two simple workflows you can audit in 30 seconds beat one clever workflow you have to reverse-engineer every time something goes wrong.

    Method 3: Conditional Coupon Based on Order Total

    Not every order deserves the same reward. A customer who spends $200 should get a better coupon than one who spends $30. Conditional branching handles this without duplicate workflows.

    After the Order Completed trigger, add a Condition node. Set the condition to check {{order_total}} against a threshold, for example greater than 150. The Yes path creates a 20% coupon.

    The No path creates a 10% coupon. The conditions and branching documentation shows the full list of operators and how to stack multiple conditions on one node.

    This approach replaces what would otherwise be two separate workflows triggered by the same event but filtered by a spend amount. You get one audit trail, one toggle, and one place to edit the thresholds.

    Method 4: PHP Hook for Scheduled Bulk Generation

    None of the existing guides connect scheduled generation all the way through. Here is the complete pattern for generating a batch of unique coupons on a recurring WP-Cron schedule, useful for loyalty programs or seasonal campaigns.

    This approach requires no additional plugins and runs entirely on your server. The tradeoff is that you are responsible for the code, and WP-Cron on low-traffic sites fires late unless you configure a real server cron. The WordPress developer documentation on WP-Cron explains how to set that up.

    Register the Schedule

    Add this to your theme’s functions.php or a site-specific plugin:

    add_action( 'wp', function() {
        if ( ! wp_next_scheduled( 'generate_loyalty_coupons' ) ) {
            wp_schedule_event( time(), 'weekly', 'generate_loyalty_coupons' );
        }
    } );
    

    Hook the Generation Function

    add_action( 'generate_loyalty_coupons', function() {
        $batch_size = 100; // adjust as needed
    
        for ( $i = 0; $i  $batch_size; $i++ ) {
            $code = 'LOYAL-' . strtoupper( wp_generate_password( 8, false ) );
    
            $coupon = array(
                'post_title'   => $code,
                'post_content' => '',
                'post_status'  => 'publish',
                'post_author'  => 1,
                'post_type'    => 'shop_coupon',
            );
    
            $coupon_id = wp_insert_post( $coupon );
    
            if ( $coupon_id ) {
                update_post_meta( $coupon_id, 'discount_type',      'percent' );
                update_post_meta( $coupon_id, 'coupon_amount',      '15' );
                update_post_meta( $coupon_id, 'usage_limit',        '1' );
                update_post_meta( $coupon_id, 'date_expires',       strtotime( '+30 days' ) );
                update_post_meta( $coupon_id, 'individual_use',     'yes' );
            }
        }
    } );
    

    This generates 100 unique codes every week, each valid for 30 days and limited to one use. Adjust $batch_size and the discount values to match your campaign. The WooCommerce coupon management documentation lists every available coupon meta key if you need to add minimum spend, exclude sale items, or restrict to specific products.

    What This Approach Does Not Handle

    • It does not assign codes to specific customers. You need a separate process to distribute them.
    • It does not send emails. Pair it with wp_mail() or a transactional email plugin for delivery.
    • It does not clean up unused codes. Add a cleanup hook if your store generates coupons over months, otherwise the shop_coupon post type grows without bound.
    • It fires late on sites with fewer than roughly 10 visitors per hour unless you replace WP-Cron with a real cron job.

    Method 5: Auto-Apply via URL

    This is the simplest option and requires no plugin and no code. WooCommerce accepts a coupon code as a URL parameter that applies the discount automatically when a customer visits the link.

    The URL pattern is:

    https://yourstore.com/?add-to-cart=PRODUCT_ID&coupon_code=YOURCODE

    Or for cart-only application:

    https://yourstore.com/cart/?coupon_code=YOURCODE

    Paste this link into an email campaign, a social post, or a banner. When a customer clicks it, the coupon applies automatically at checkout. No copy-paste required on their end.

    The limitation is that the same code applies every time. This works well for campaign-wide discounts but not for personalized or single-use rewards. For the latter, use Method 1 or Method 2.

    Comparing All Five Methods

    Method Setup Time (estimate) Unique Code Per Customer Sends Email Automatically Requires Code
    Visual workflow (order) 10 to 15 minutes Yes Yes No
    Visual workflow (registration) 10 to 15 minutes Yes Yes No
    Conditional workflow (spend tier) 20 to 30 minutes Yes Yes No
    PHP + WP-Cron batch 30 to 60 minutes Yes (batch) No (manual step) Yes
    Auto-apply URL Under 5 minutes No No (you email the link) No

    The PHP approach gives you maximum control. It also gives you maximum responsibility. If something breaks at 2am, there is no support ticket to open.

    What to Check if the Coupon Does Not Arrive

    Work through these in order. Each check takes under two minutes, and skipping ahead wastes time if the issue is upstream.

    1. Check the execution log first. In Krom Automation, go to Krom Automation → Logs. Find the run for the order in question. The per-step view shows whether the Create Coupon action succeeded and whether the Send Email action fired. If the coupon was created but the email did not send, the issue is in your WordPress email configuration, not the workflow.
    2. Confirm the trigger fired. The workflow must be set to Active and the order must have reached the exact status you chose. Order Created fires on payment. Order Completed fires when you manually mark an order complete or when it transitions automatically via your fulfillment settings.
    3. Check WooCommerce coupon restrictions. Go to Marketing → Coupons and find the generated coupon. Open it and check the Usage Restriction tab. If the customer’s email is not on the allowed list and you restricted to specific emails, the coupon will not apply even though it was created correctly.
    4. Check your email delivery. WordPress’s default wp_mail() function fails silently on many shared hosts. Install a transactional email plugin like WP Mail SMTP and confirm delivery through your SMTP provider’s logs.
    5. Rerun the simulator. The workflow simulator lets you replay a workflow against a specific order ID without creating a new order. Use it to confirm the merge tags resolve to the values you expect.

    Extending the Workflow

    The same coupon creation action connects to a wider set of triggers than just WooCommerce orders. Here are four setups worth considering once the basics are running:

    • After a form submission: Use a Gravity Forms trigger or a WPForms trigger to issue a coupon when someone completes a lead magnet form.
    • After a subscription renews: The WooCommerce Subscriptions integration exposes renewal events as triggers, so you can reward long-term subscribers automatically.
    • After a course is completed: The LearnDash integration fires on course completion, making it straightforward to offer a product discount as a graduation reward.
    • After a membership is activated: The MemberPress integration covers signup and payment events, so a welcome coupon for new members takes about 10 minutes to set up.

    If you want a detailed walkthrough of the specific case where a coupon follows a first purchase, we have a dedicated post on how to send a coupon after a customer’s first WooCommerce order that covers the first-order filter logic in full.

    Also Worth Knowing About

    Pollify is wpRigel’s poll, survey, and quiz plugin for WordPress. It builds natively inside the block editor as real Gutenberg blocks, so there are no shortcodes to paste and no separate interface to learn. If you want to survey customers after a purchase, Pollify sits right inside the post editor alongside your content.

    Commandify is a command palette for the WordPress admin. Press Cmd or Ctrl plus K to jump anywhere, search orders, customers, and products, and run admin actions without navigating menus. It is the only command palette with real WooCommerce order, product, and customer commands built in, which makes it genuinely useful for anyone managing a busy store.

    Next Steps

    If your goal is a unique coupon per customer sent automatically on a trigger, the visual workflow approach gets you there in under 20 minutes with no code and a full execution log to audit. If you need scheduled bulk generation for a campaign, the PHP method gives you that at zero plugin cost, provided you are comfortable maintaining the code. Start with the method that matches your use case, test it on a staging order before going live, and use the execution log to confirm every step ran as expected.

    Try Krom Automation free on WordPress.org

    Frequently Asked Questions

    How do I automatically apply a WooCommerce coupon without customers entering a code?

    Add ?coupon_code=YOURCODE to any cart or checkout URL. When a customer clicks the link, WooCommerce applies the coupon automatically at checkout. This works with any existing coupon and requires no plugin.

    Can I auto-generate a unique coupon code for each customer after they order?

    Yes. Use an Order Completed trigger connected to a Create Coupon action. Set the coupon code field to a combination of a static prefix and the {{order_id}} merge tag.

    That produces a unique, readable code for every order. Set the usage limit to 1 so the code cannot be shared.

    How do I create a WooCommerce coupon programmatically using PHP?

    Use wp_insert_post() with post_type set to shop_coupon, then set coupon properties via update_post_meta(). The key meta fields are discount_type, coupon_amount, usage_limit, and date_expires. The full list of meta keys is in the WooCommerce coupon documentation.

    How do I set an automatic expiry date on generated WooCommerce coupons?

    In a PHP-generated coupon, set the date_expires meta value to a Unix timestamp, for example strtotime( '+30 days' ). In a visual workflow, enter a fixed date in the expiry field of the Create Coupon action, or use a delay node before a secondary action that updates the coupon record.

    What is the difference between Order Created and Order Completed as a trigger for coupon automation?

    Order Created fires when payment is confirmed, before fulfillment. Order Completed fires when the order status changes to “Completed,” which is usually after you ship the item or manually update the status.

    Use Order Created for instant post-purchase coupons. Use Order Completed for loyalty rewards tied to delivery or fulfillment.

    The wpRigel Team

    November 16, 2026
    Krom Automation, WooCommerce
  • How to Send an SMS When a WordPress Form Is Submitted

    You can send an SMS when a WordPress form is submitted by pairing your form plugin with Twilio and a workflow layer that sits between them. WordPress has no built-in SMS feature, so you need three things: a form plugin, an SMS gateway account (Twilio is the standard choice), and something to connect the two and fire the message automatically on each submission.

    This tutorial uses a visual workflow builder to make that connection. The same logic applies regardless of which form plugin you use, because the workflow layer handles the routing.

    We tested this setup on Contact Form 7, WPForms, Gravity Forms, Fluent Forms, Ninja Forms, and Elementor Forms. All of them work.

    Before we get into steps, one thing worth knowing: every approach covered by competing guides assumes the happy path works perfectly. This one does not. We cover what breaks, what the error messages mean, and how to get delivery receipts you can actually check.

    What You Need Before You Start

    • A form plugin already installed with at least one live form collecting submissions.
    • A Twilio account with a verified phone number and enough credit. Twilio’s trial accounts restrict sending to verified numbers only, which is enough for testing but not for live sites. See Twilio’s SMS quickstart documentation for account setup.
    • Your Twilio credentials: Account SID, Auth Token, and the sending phone number. All three live in the Twilio Console under Account Info.
    • A workflow automation plugin installed and active on your WordPress site. The steps below use Krom Automation, which handles the form trigger, the Twilio connection, and the message body all in one canvas.

    If you are starting from scratch, the installation guide takes under five minutes. Once active, you will see a Krom Automation menu item in your WordPress admin sidebar.

    Step 1: Connect Your Form Plugin as the Trigger

    Open Krom Automation and click Add New Workflow. You will land on the visual canvas. Click the trigger node (the top card on the canvas) and search for your form plugin by name.

    The supported form triggers include Contact Form 7, WPForms, Gravity Forms, Fluent Forms, Ninja Forms, and Elementor Forms. Each one fires when a form is submitted on your site.

    After selecting the trigger, you will see a dropdown listing every form currently active on your site. Select the specific form you want to respond to, or leave it set to “Any form” if you want the workflow to fire for all submissions.

    Documentation for each form plugin integration covers the exact fields each trigger exposes:

    • Contact Form 7 integration: triggers, actions, and automation examples
    • WPForms integration: triggers, actions, and automation examples
    • Gravity Forms integration: triggers, actions, and automation examples
    • Fluent Forms integration: trigger, setup, and automation examples
    • Ninja Forms integration: trigger, setup, and automation examples
    • Elementor Forms integration: trigger, setup, and automation examples

    Step 2: Add the Twilio Action

    Click the + button below the trigger node to add an action. Search for “Twilio” and select Send SMS. You will see three fields: To Number, From Number, and Message Body.

    The To Number field accepts a static phone number or a merge tag that pulls the submitter’s number from the form. If your form collects the submitter’s phone number, you can reference it here with a merge tag such as {{field:phone}}.

    The exact tag name depends on your form plugin and what you named the field. See the merge tags documentation for the full syntax.

    The From Number must match the Twilio phone number you provisioned. Enter it in E.164 format: +1 followed by the area code and number for US numbers, for example +12025551234.

    The Message Body supports free text and merge tags together. A useful admin alert might read: “New submission from {{field:name}}, {{field:email}}. Submitted at {{submission:date}}.” Keep messages under 160 characters to avoid multi-part SMS charges, which Twilio bills per segment.

    An SMS that just says “New form submission” is almost useless. Including the submitter’s name and email in the message body is the difference between a notification and actual information.

    Step 3: Enter Your Twilio Credentials

    When you select the Twilio action for the first time, the panel asks for your Account SID and Auth Token. These authenticate every API call the workflow makes. Paste them from the Twilio Console and click Save Connection.

    The credential is stored once at the site level and reused across all workflows. You do not re-enter it for each workflow you build. If you ever rotate your Twilio credentials, update them once in the connections panel and all workflows pick up the change immediately.

    For the full setup reference covering Twilio alongside Slack, Discord, and Telegram, see the messaging integrations documentation.

    Step 4: Send SMS to Both Admin and Submitter

    A common need is to notify two people on a single submission: the site admin gets an alert, and the submitter gets a confirmation. You can do both in one workflow.

    After the first Twilio action node, click + again to add a second Twilio action beneath it. The first action targets your admin number (a fixed value).

    The second targets the submitter’s number via merge tag. Both fire in sequence every time the form is submitted.

    If you only want the confirmation SMS to send when the submitter’s phone field is filled in (since it may be optional), add a conditional branch between the trigger and the second action. Set the condition to check whether the phone field is not empty.

    The Yes path fires the SMS; the No path does nothing. This prevents Twilio errors from blank number fields, which is one of the most common failure causes in production.

    Step 5: Route Different Forms to Different Recipients

    Agencies and teams often need form-specific routing. A contact form goes to the sales team.

    A support form goes to the helpdesk number. A job application form goes to HR.

    The cleanest way to handle this is one workflow per form. Set each workflow’s trigger to a specific form rather than “Any form”, then set the Twilio To Number to the team phone number for that form. Each workflow is independent, so enabling, disabling, or editing one has no effect on the others.

    If you have many forms and prefer a single workflow, you can use conditional branching on a hidden field that identifies the form source. The conditions and branching documentation covers multi-path logic in detail.

    One workflow per form is almost always the right choice. It is easier to debug, easier to disable one form without touching others, and easier to hand off to a client.

    Step 6: Test Before Going Live

    Use the workflow simulator to do a dry run with zero side effects. The simulator fires the workflow logic and shows you what each node would receive and send, without actually calling the Twilio API or delivering a real SMS.

    Once the simulator confirms the logic is correct, submit your form for real. Open the workflow’s execution log immediately after.

    You will see a row for the submission with a status of Success or Failed, the exact payload sent to Twilio, and the response Twilio returned. That response is the most useful debugging tool you have.

    What to Do When SMS Fails to Send

    Every guide on this topic assumes the happy path. Here is what actually breaks and how to fix it.

    Failure Checklist: Work Through These in Order

    1. Check the execution log first. Open the workflow, click Execution History, and find the failed run. The log shows the exact Twilio API response code. That code tells you everything.
    2. Error 21211 (Invalid To phone number). The number in the To field is not in E.164 format, or the form field was empty. Add the conditional branch described in Step 4 to catch empty fields before the Twilio action fires.
    3. Error 21608 (Unverified number on trial account). Twilio trial accounts can only send to numbers you have explicitly verified in the console. Either verify the number in Twilio or upgrade to a paid account.
    4. Error 20003 (Authentication failure). Your Account SID or Auth Token is wrong. Return to the connections panel, re-enter both values, and re-save.
    5. Error 21614 (Not a mobile number). The destination number is a landline. Twilio cannot deliver SMS to landlines. Validate phone number format in your form before submission if this is a recurring issue.
    6. Workflow never fires at all. Check whether the form plugin integration is active under Krom Automation’s integrations panel. Some form plugins require a small compatibility setting to be enabled. Also confirm the workflow itself is set to Active, not Paused.
    7. SMS sends but arrives late. The workflow runs via WordPress Cron (Action Scheduler). On very low-traffic sites, WP-Cron fires late when no page loads occur. Configure a real server-side cron job to call wp-cron.php every minute. See WordPress.org’s documentation on hooking WP-Cron into the system task scheduler.

    Automatic Retry and Failure Notifications

    When an action fails, the workflow engine automatically retries with configurable backoff. You also receive a failure notification by email so you are not discovering problems hours later when a lead has already gone cold. The execution log keeps a full per-step audit trail, so you can see exactly which step failed and what the upstream service returned.

    Including Form Field Data in the SMS Body

    Merge tags let you inject live submission data into the SMS message body. The tag format is {{field:field_name}} where field_name matches the field identifier in your form plugin.

    What you want in the SMS Example merge tag Notes
    Submitter’s name {{field:name}} Use the field’s slug, not its label
    Submitter’s email {{field:email}} Useful for admin follow-up
    Submitter’s phone {{field:phone}} Can be used as the To Number directly
    Form name {{form:title}} Helpful when one workflow covers multiple forms
    Submission date and time {{submission:date}} Formats to your WordPress timezone setting
    Any custom field {{field:your_field_slug}} Check your form plugin for the field slug

    Keep the total character count in mind. A standard SMS segment is 160 characters.

    Twilio charges per segment, so a 320-character message costs twice as much as a 160-character one. For admin alerts, name, email, and timestamp in 160 characters is usually enough.

    Cost Comparison: Approaches Side by Side

    There are three practical approaches to sending SMS on form submission in WordPress. Here is what each one costs and what it trades off, so you can decide before committing time to setup.

    Approach Year 1 cost (estimate) Execution limit Debugging visibility Multi-form routing
    Workflow plugin (free tier) + Twilio Twilio API cost only (~$0.0079 per SMS in US, at time of writing) No run caps on free tier Full per-step execution log Yes, one workflow per form
    WPForms + Twilio Add-On WPForms Elite ~$299/year + Twilio costs No run caps Limited, no per-step log Yes, per form setting
    Zapier (WPForms + Twilio Zap) ~$240/year for 750 tasks/month, as of September 2026 750 tasks/month on Professional plan, overages charged Zap history, 7 days on free Yes, one Zap per form

    The workflow plugin approach carries no per-task charge at any tier. You pay Twilio directly for each SMS at their standard rate, which is roughly $0.0079 per outbound message in the US (this figure comes from Twilio’s published SMS pricing page and is subject to change). At 500 form submissions a month, that is under $4 in SMS costs with no platform surcharge on top.

    Per-task billing punishes success. A site that doubles its form submissions doubles its automation bill overnight, with no warning and no way to cap it.

    How to Add a Delay Before Sending

    Some use cases need a gap between form submission and SMS delivery. A booking confirmation might send immediately, but a follow-up reminder might go out 24 hours later. You can add a delay node between the trigger and the Twilio action by clicking the + and selecting Delay.

    Set the delay to any number of minutes, hours, days, or weeks. The workflow pauses at that node and resumes when the delay expires, using Action Scheduler to run in the background without holding up page loads. The delays and scheduling documentation covers the full configuration.

    Other Tools Worth Knowing About

    If you are building a form submission pipeline, you will likely want to do more than send one SMS. Pollify is wpRigel’s Gutenberg-native poll and survey plugin.

    It builds polls as real blocks inside the editor, so there are no shortcodes to paste and no separate interface to manage. It pairs well with form-based workflows when you need quick structured feedback rather than a full form.

    Commandify is a command palette for the WordPress admin. Press Cmd or Ctrl plus K to jump to any screen, search content, or run admin actions without navigating menus.

    It is the only WordPress command palette with real WooCommerce order, product, and customer commands built in. For teams managing multiple sites or workflows, it removes a significant amount of daily clicking.

    Next Steps

    The setup described here takes roughly 15 to 20 minutes from a fresh install to a working SMS notification on form submission. The Twilio trial account is enough to test with.

    Once you have confirmed the message arrives correctly and the execution log shows a clean run, you can extend the same workflow to add a second SMS for the submitter, a conditional branch for optional phone fields, or a delay for follow-up messages. Each of those is an additional node on the same canvas, not a separate plugin or integration to configure.

    Try Krom Automation free on WordPress.org

    Frequently Asked Questions

    Does WordPress have built-in SMS, or do I need a plugin?

    WordPress has no built-in SMS feature. You need a form plugin, an SMS gateway account (Twilio is the standard choice), and a workflow layer to connect them. The workflow layer handles authentication, message formatting, and retry logic when delivery fails.

    Can I send SMS without a Twilio account?

    Twilio is the most widely supported gateway for WordPress automation. Some alternative gateways exist, such as ClickSend and Vonage, but Twilio has the broadest documentation and the most reliable deliverability. If you use a different gateway that exposes an HTTP API, you can connect to it via an HTTP Request action, though this requires more configuration than a native Twilio integration.

    Can I include what the user typed into the form inside the SMS?

    Yes. Merge tags let you insert any form field value into the SMS message body.

    Use the syntax {{field:field_slug}} where the field slug matches your form plugin’s field identifier. The merge tags documentation explains how to find field slugs for each supported form plugin.

    What happens if the SMS fails to deliver?

    The execution log records the exact Twilio response code for every failed delivery. The most common causes are an invalid phone number format (error 21211), an unverified number on a Twilio trial account (error 21608), or wrong API credentials (error 20003). The workflow engine retries automatically on transient failures and sends a failure notification email so you are not discovering problems hours later.

    Can different forms send SMS to different recipients?

    Yes. Create one workflow per form, set each trigger to a specific form, and set each Twilio action’s To Number to the relevant recipient. This keeps each form’s routing independent so you can enable, disable, or edit one without affecting the others.

    The wpRigel Team

    November 13, 2026
    Krom Automation
  • How to Post WordPress Posts to Discord Automatically

    You can post WordPress posts to Discord automatically by creating a webhook URL inside Discord, then connecting it to a WordPress automation workflow that fires on the “Post Published” trigger. The whole setup takes under 10 minutes, works on the free tier, and requires no custom code.

    What most tutorials skip is what happens after the happy path: a webhook call that times out, a post that fires to the wrong channel, or a category you never wanted syndicated. This guide covers the full setup and those edge cases, so you have something that actually holds up in production.

    We tested this in our own staging environment using WordPress 6.5 and a live Discord server with three channels. Everything below reflects what we saw on screen.

    What You Need Before You Start

    • A Discord server where you have Manage Webhooks permission on at least one channel.
    • WordPress 6.2 or higher with PHP 7.4 or higher.
    • An automation plugin that supports a Post Published trigger and an HTTP Request action. The free version of Krom Automation covers both out of the box.
    • Five to ten minutes for the initial setup. Conditional logic and multi-channel routing add another five.

    You do not need a Discord bot token for this approach. Webhooks are simpler, require no OAuth flow, and are sufficient for one-way notifications from WordPress to Discord. The bot-token approach adds complexity only when you need two-way interaction, such as reading Discord messages from WordPress, which is a different problem entirely.

    Step 1: Create a Discord Webhook URL

    Open Discord and go to the channel you want to receive WordPress posts. Click the gear icon next to the channel name to open Edit Channel. Navigate to Integrations, then Webhooks, and click New Webhook.

    Give the webhook a name that makes its source obvious, something like “WordPress Blog Posts”. Copy the webhook URL to your clipboard.

    It will look like https://discord.com/api/webhooks/[ID]/[TOKEN]. Store it somewhere safe; you will paste it into WordPress in the next step.

    Discord’s official documentation covers webhook creation in detail. See the Discord webhook reference for the full field reference if you need to customise the payload later.

    Step 2: Install Your Automation Plugin

    In your WordPress admin, go to Plugins > Add New and search for “Krom Automation”. Install and activate it.

    The plugin adds a Krom Automation menu item to your sidebar. No account creation is required and nothing is gated behind a paywall in the free version.

    If you have never built a workflow before, the how Krom Automation works overview explains triggers, actions and the visual canvas in about three minutes of reading. For the installation steps themselves, see how to install Krom Automation on WordPress.

    Step 3: Build the Workflow

    Go to Krom Automation > Workflows > Add New. You will land on a drag-and-drop canvas. The workflow starts with a trigger node and you connect action nodes to it.

    1. Add the trigger: Click the trigger node and select Post Published from the Post category. This fires every time a post transitions to published status, including scheduled posts that go live at their scheduled time.
    2. Add the action: Click the plus icon below the trigger to add an action. Select HTTP Request from the Integration category.
    3. Configure the HTTP Request: Set the method to POST. Paste your Discord webhook URL into the URL field.
    4. Set the Content-Type header: Add a header with the key Content-Type and the value application/json. Discord requires this for webhook payloads.
    5. Write the request body: Paste the JSON below into the body field, using merge tags to inject real post data.

    Here is the payload that produces a clean Discord notification with the post title and a direct link:

    {
      "content": "New post: **{{post_title}}** {{post_url}}"
    }

    Merge tags pull live data from the event that fired the trigger. {{post_title}} resolves to the actual title of the published post and {{post_url}} resolves to its permalink. For the full list of available variables, see the merge tags documentation.

    Save the workflow and toggle it to Active.

    Every other tutorial shows the webhook URL going in. None of them show what the payload looks like when it arrives in Discord, which is the part that determines whether anyone actually reads it.

    Step 4: Test Before You Go Live

    Before you publish a real post, use the built-in workflow simulator to run a dry test with zero side effects. Open the workflow, click Simulate, and choose a recent post as the sample data. The simulator walks through each node and shows you exactly what payload would be sent to Discord, without actually sending it.

    See the testing workflows with the simulator documentation for the full walkthrough. Once the simulation looks right, publish a draft post and watch your Discord channel for the notification. It should arrive within a few seconds on a standard host.

    Conditional Logic: Post Only Specific Categories

    The basic workflow fires for every published post. If you run a site with ten post types or twenty categories, you almost certainly do not want all of them going to Discord. Here is how to add a filter.

    Between the trigger and the HTTP Request action, add a Condition node. Conditions create a Yes path and a No path. Set the condition to check whether the post category equals the category you want to syndicate, for example “News” or “Product Updates”.

    Connect the HTTP Request to the Yes path only. Posts in other categories reach the No path and exit the workflow without sending anything.

    You can stack multiple conditions to route different categories to different Discord channels. Each channel needs its own webhook URL and each path gets its own HTTP Request action with the matching URL. The conditions and branching documentation shows how to build multi-path workflows step by step.

    For the visual canvas itself, the visual workflow builder guide explains how to connect nodes, navigate the canvas, and rearrange your layout as the workflow grows.

    Failure Handling: What Happens When the Webhook Call Fails

    This is the section no other guide covers. Discord webhooks return a non-200 status code for several real-world reasons: the webhook was deleted from the Discord server, the server is temporarily unavailable, or your host’s outbound HTTP is blocked on certain ports. Without failure handling, you lose the notification silently and never know.

    Krom Automation handles this in two ways. First, failed executions are logged in the execution history with a full per-step audit trail, so you can see which workflow step failed and what error code Discord returned. Second, the plugin sends an email notification to the site admin when an execution fails, and retries automatically with configurable backoff.

    Failure scenario What you see What to do
    Discord webhook was deleted HTTP 404 in execution log Generate a new webhook URL in Discord and update the workflow
    Incorrect Content-Type header HTTP 400, Discord returns “Invalid JSON” Confirm the header is set to application/json exactly
    Rate limit hit (Discord allows 30 requests per 60 seconds per webhook) HTTP 429, retry-after header present Add a delay node before the HTTP Request to space out bulk publishes
    Host blocks outbound HTTP on port 443 cURL error or timeout in execution log Contact your host; most managed WordPress hosts allow outbound HTTPS by default
    Malformed merge tag in the payload HTTP 400 or empty field in Discord message Run the simulator first to preview the resolved payload before activating

    The send a webhook when a WordPress post is published post goes deeper on the HTTP Request action and payload structure if you want to build a richer embed rather than a plain text message.

    Silent failures are the worst kind. A workflow that fails 20 percent of the time looks identical to a working one until you check the execution log. That log is the reason execution history matters more than the feature list suggests.

    Richer Discord Embeds vs. Plain Text Messages

    The basic payload sends a plain text line. Discord also supports rich embeds with a title, description, URL, thumbnail image and colour strip. To use an embed, change the payload body to this structure:

    {
      "embeds": [{
        "title": "{{post_title}}",
        "url": "{{post_url}}",
        "description": "{{post_excerpt}}",
        "color": 5814783
      }]
    }

    The color field accepts a decimal integer. The value 5814783 is a mid-blue.

    Convert any hex colour to decimal before inserting it. The {{post_excerpt}} merge tag pulls the post excerpt, which you can set manually in the WordPress post editor or leave blank to let WordPress auto-generate one from the first paragraph.

    Keep the embed description under 200 characters. Discord truncates longer descriptions in the channel preview, which makes the notification harder to read at a glance.

    Webhook-Only vs. Bot Token: Which Should You Use?

    Dimension Webhook approach Bot token approach
    Setup time Under 10 minutes 30 to 60 minutes including Discord Developer Portal registration
    Direction WordPress to Discord only (one-way) Both directions, bot can read and write
    Permissions required Manage Webhooks on one channel Bot must be invited to the server with specific permission scopes
    Rate limit 30 requests per 60 seconds per webhook 50 requests per second globally, per bot
    Maintenance burden Low. Webhook URL is static until deleted. Medium. Bot token must be rotated if compromised.
    Suitable for Publishing notifications, content alerts Interactive commands, two-way sync, moderation bots

    For the use case in this article, publishing a WordPress post to a Discord channel, the webhook approach is correct. It is simpler, requires fewer permissions, and there is no token to manage. The bot token approach is worth the extra complexity only when you need Discord to do something back toward your WordPress site.

    Does This Work for WooCommerce Products?

    Yes. The free version of the plugin includes both an Order Created trigger and an Order Completed trigger. You can notify a Discord channel whenever a WooCommerce order comes in, with the order total and customer name in the payload, using exactly the same HTTP Request action and the same webhook setup described above.

    For product-level events, such as notifying a Discord channel when a product goes back in stock or when a subscription renews, those require Pro triggers. The WooCommerce Subscriptions integration documentation lists the available triggers and what data each one exposes as merge tags.

    If you also send post notifications to Slack, the same workflow pattern applies. The messaging integrations overview covers Discord, Slack, Twilio and Telegram side by side.

    Timing: How Fast Does a Post Appear in Discord?

    On a standard shared host with WP-Cron running normally, the notification reaches Discord within 2 to 5 seconds of publish. The HTTP Request action runs in the background via Action Scheduler, so the publish action itself is not blocked or slowed down.

    On very low-traffic sites where WP-Cron only fires when a visitor loads a page, there can be a delay if no one visits the site for several minutes after publishing. The fix is to disable WP-Cron’s default behaviour and run it as a real server cron job instead.

    The WordPress developer documentation on hooking WP-Cron into the system task scheduler covers this setup. This is worth doing on any site where timing reliability matters.

    Also Worth Knowing About

    Pollify is wpRigel’s poll, survey and quiz plugin for WordPress. It builds natively inside the block editor as real Gutenberg blocks, so there are no shortcodes to paste and no separate interface to configure. It is worth knowing about if you gather community feedback on the same site you are syndicating to Discord.

    Commandify is a command palette for the WordPress admin. Press Cmd or Ctrl plus K to search content, jump to any settings screen, and run admin actions without clicking through menus. It is the only WordPress command palette with real WooCommerce order, product and customer commands built in.

    Frequently Asked Questions

    Is there a free way to auto-post WordPress posts to Discord without a paid plugin?

    Yes. The free version of Krom Automation includes the Post Published trigger and the HTTP Request action, which is everything you need for this setup.

    There is no run cap, no trial period, and nothing behind a paywall in the free version. Download it free from the WordPress.org plugin directory.

    How do I post only specific categories from WordPress to Discord?

    Add a Condition node between the Post Published trigger and the HTTP Request action. Set the condition to check the post category and connect the HTTP Request to the Yes path only. Posts in other categories exit the workflow without triggering the webhook call.

    Why is my WordPress post not showing up in Discord after I publish?

    Check the execution log in Krom Automation first. The most common causes are a deleted or incorrect webhook URL (Discord returns 404), a missing Content-Type header (Discord returns 400), or a WP-Cron delay on low-traffic sites. The execution log shows the exact HTTP status code Discord returned, which narrows the problem immediately.

    Can I send posts to multiple Discord channels?

    Yes. Add separate HTTP Request action nodes for each channel, each with its own webhook URL. Use Condition nodes to route different post categories to different channels, or duplicate the HTTP Request action to send the same post to two channels simultaneously.

    Does this work with scheduled posts or only with immediately published posts?

    Both. The Post Published trigger fires whenever a post transitions to published status, including scheduled posts that go live at their set time. There is no separate trigger needed for scheduled content.

    If you also notify subscribers by email when a post goes live, the email subscribers when a new WordPress post is published post shows how to combine both notifications in a single workflow using parallel action nodes.

    Try Krom Automation free on WordPress.org

    The wpRigel Team

    November 11, 2026
    Krom Automation, User Engagement
  • How to Send a Webhook When a WordPress Post Is Published

    The cleanest way to send a webhook when a post is published in WordPress is to hook into the transition_post_status action and fire an HTTP POST using wp_remote_post(). If you want retry logic, execution logs and a visual editor instead of code, a workflow plugin handles all of that in about five minutes. This tutorial covers both paths, including the failure-handling gap that every other guide skips.

    We tested both approaches on WordPress 6.5 with PHP 8.2. The code path works on any host.

    The plugin path works on shared hosting too, because it queues requests through Action Scheduler rather than firing them synchronously during the publish request. That difference matters more than most tutorials admit.

    Before you choose a path, it helps to understand what can go wrong. When WordPress publishes a post, the browser is waiting. If your webhook fires synchronously during that same request and the receiving endpoint takes three seconds to respond, the editor hangs for three seconds.

    If the endpoint is down, the webhook fails silently with no log and no retry. Neither the code snippets on most blogs nor the basic plugin guides address this, so we will.

    Which Approach Is Right for You?

    SituationBest pathWhy
    One webhook, one destination, no retry neededCode snippetZero plugin overhead, deployed in under 10 minutes
    Multiple webhooks or multiple post typesWorkflow pluginConditional logic without stacking if statements
    Need retry on failure or execution logsWorkflow pluginAutomatic retry with backoff; per-step audit trail
    Sending to Slack, Discord or a CRMWorkflow pluginNative integrations replace hand-rolled JSON formatting
    Shared hosting with no server cronWorkflow pluginAction Scheduler decouples execution from the publish request
    Client site, no code deploymentsWorkflow pluginNon-developers can edit triggers without touching functions.php

    Path 1: The Code Approach

    The correct hook is transition_post_status, not publish_post. The difference is important: publish_post fires on every save to a published post, including updates. transition_post_status lets you check the previous status, so you can fire only on the transition from any status to publish for the first time.

    Add this to your theme’s functions.php or, better, a site-specific plugin so it survives theme changes. The WordPress developer documentation for transition_post_status covers all the parameters.

    add_action( 'transition_post_status', 'my_send_publish_webhook', 10, 3 );
    
    function my_send_publish_webhook( $new_status, $old_status, $post ) {
        // Fire only on the first publish, not on updates
        if ( $new_status !== 'publish' || $old_status === 'publish' ) {
            return;
        }
    
        // Restrict to a specific post type if needed
        if ( $post->post_type !== 'post' ) {
            return;
        }
    
        $payload = wp_json_encode( array(
            'post_id'       => $post->ID,
            'title'         => get_the_title( $post ),
            'url'           => get_permalink( $post ),
            'thumbnail_url' => get_the_post_thumbnail_url( $post, 'full' ),
            'published_at'  => get_the_date( 'c', $post ),
            'categories'    => wp_get_post_categories( $post->ID, array( 'fields' => 'names' ) ),
        ) );
    
        wp_remote_post( 'https://your-endpoint.example.com/hook', array(
            'body'        => $payload,
            'headers'     => array( 'Content-Type' => 'application/json' ),
            'timeout'     => 5,
            'blocking'    => false, // Non-blocking: does not hold up the editor
        ) );
    }

    Setting blocking to false is the most important line in that snippet. With blocking => false, WordPress fires the request and immediately moves on.

    The editor does not hang while waiting for a response. The trade-off is that you get no response body and no way to detect failure at the point of sending.

    Non-blocking solves the latency problem and creates the reliability problem. You cannot have both without a queue.

    Firing Only on First Publish, Not on Every Edit

    The $old_status === 'publish' check is what prevents the webhook from firing again every time the post is edited after it goes live. Without that guard, updating the title six months later fires the webhook again, which breaks most downstream integrations. This is the most common cause of duplicate webhook deliveries, and it is not mentioned in most tutorials.

    Restricting to a Post Type or Category

    To fire only for a specific post type, change $post->post_type !== 'post' to match the post type slug you want, for example !== 'product' or !== 'news'. To fire only for posts in a specific category, add a check after the post type guard:

    $categories = wp_get_post_categories( $post->ID );
    if ( ! in_array( 42, $categories ) ) { // 42 is your category term ID
        return;
    }

    What the Code Path Does Not Give You

    • No retry: if the endpoint returns a 500 or times out, the webhook is lost with no record of the attempt.
    • No logs: you have no way to see which posts triggered the webhook, what was sent, or whether it arrived.
    • No dry-run testing: you must publish a real post to test, which pollutes your site with test content.
    • No visual editing: changing the payload or the endpoint means editing PHP code and redeploying.

    For a single low-stakes webhook to a reliable endpoint, those limitations are acceptable. For anything more critical, the next path is worth the five minutes of setup.

    Path 2: The No-Code Workflow Approach

    Krom Automation is a visual workflow plugin for WordPress. It includes a Post Published trigger and an HTTP Request action in the free version, so this entire workflow costs nothing.

    Execution runs through Action Scheduler, which means the webhook fires after the publish request completes, not during it. That solves the synchronous timing problem without any code.

    Install the free plugin from the WordPress.org plugin directory. If you have not installed it before, the installation guide walks through the first activation steps.

    Step 1: Create a New Workflow

    Go to Krom Automation in your WordPress admin sidebar and click Add New Workflow. You will see a blank canvas with a prompt to add a trigger. Click the trigger node to open the trigger selector panel on the right.

    Step 2: Set the Trigger to Post Published

    In the trigger panel, choose Post from the category list, then select Post Published. You will see configuration options appear below the trigger selector:

    • Post type: choose Post, Page, or any custom post type registered on your site.
    • Category filter: leave blank to fire for all categories, or enter one or more category slugs to restrict.
    • Run once per post: this toggle is on by default and prevents the workflow from firing again if the post is later updated. Leave it on.

    The full list of available triggers and their configuration options is documented in the free triggers reference.

    Step 3: Add an HTTP Request Action

    Click the plus icon below the trigger node to add an action. Choose Integration from the action categories, then select HTTP Request. The action panel opens with these fields:

    • URL: paste your destination endpoint URL here.
    • Method: select POST.
    • Headers: add Content-Type: application/json.
    • Body: paste your JSON payload here, using merge tags for dynamic values.

    Step 4: Build the Payload with Merge Tags

    Merge tags pull live data from the trigger event into any action field. In the body field, build your payload like this:

    {
      "post_id": "{{post.id}}",
      "title": "{{post.title}}",
      "url": "{{post.permalink}}",
      "thumbnail_url": "{{post.thumbnail_url}}",
      "published_at": "{{post.published_date}}",
      "author": "{{post.author_name}}"
    }

    The merge tags documentation lists every available variable for post triggers, including custom field values and taxonomy terms. Click the {} merge tags button in any field to browse available tags without memorising them.

    Step 5: Add Conditional Logic (Optional)

    If you want the webhook to fire only when a post meets additional conditions, such as being in a specific category or having a certain custom field value, click the branching icon on the action node to add a condition. The conditions and branching documentation covers the full logic options. Connect the HTTP Request action to the Yes path and the workflow ends on the No path with no action taken.

    Step 6: Test with the Workflow Simulator

    Before going live, click the Simulate button in the top toolbar. The simulator runs the workflow with real post data and shows you exactly what would have been sent to your endpoint, including the resolved merge tag values, without actually firing the HTTP request. This is covered in the workflow simulator documentation.

    Once the simulated payload looks correct, toggle the workflow to Active and publish a test post. The execution log will show the request status, the response code from your endpoint, and each step’s outcome.

    A webhook that fails silently is worse than no webhook at all. At least when nothing is configured, you know nothing is running.

    What Happens When the Endpoint Is Down

    This is the question every other guide skips. When you fire a webhook synchronously in PHP and the endpoint returns a 503, the request fails and nothing happens.

    You will not know unless you are actively watching server logs. For teams sending post data to a CRM, a Slack channel, or a build pipeline, that silent failure can go unnoticed for days.

    The workflow plugin approach handles this differently. Failed HTTP Request actions are logged in the execution history with the response code and error message.

    Automatic retry kicks in with configurable backoff, so a temporary outage at the endpoint does not lose the event. Email notifications alert you when a workflow fails, and the analytics dashboard shows a failed execution count so trends are visible at a glance.

    If you are using the code path and need similar reliability, you can defer the webhook using wp_schedule_single_event() to push it off the publish request and onto the next WP-Cron pass. The WordPress developer reference for wp_schedule_single_event explains the parameters. This adds async behaviour but still gives you no retry logic or logs without building them yourself.

    Sending to Slack or Discord

    For Slack and Discord, the HTTP Request action works with their incoming webhook URLs. Format the payload to match the channel’s expected structure. Slack expects a JSON body with a text key or a blocks array.

    Discord expects a content key. The messaging integrations documentation shows the exact payload structure for both platforms.

    If you also want to notify email subscribers when a post is published, our guide on emailing subscribers when a new post is published covers that workflow alongside the webhook setup.

    Common Failure Modes and Fixes

    SymptomLikely causeFix
    Webhook fires on every post edit, not just first publishUsing publish_post hook without status guardSwitch to transition_post_status and check $old_status !== 'publish'
    Webhook fires twice for the same postTwo hooks registered, or autosave triggering the actionAdd a transient lock: set a transient keyed to post ID, skip if it exists
    Editor hangs after clicking PublishSynchronous wp_remote_post() with slow endpointSet blocking => false or switch to queued execution via plugin
    Webhook body arrives empty at destinationContent-Type header missing, endpoint expects form dataAdd Content-Type: application/json header; confirm endpoint accepts JSON
    Webhook never fires on a staging siteWP-Cron disabled or Action Scheduler not runningConfirm DISABLE_WP_CRON is not set to true in wp-config.php
    Thumbnail URL returns false in payloadPost has no featured image setUse a fallback: get_the_post_thumbnail_url( $post, 'full' ) ?: ''

    What Gets Sent: A Reference Payload

    This is the payload structure we use in production for a standard blog post notification. It covers the fields most downstream services actually need.

    {
      "post_id": 1842,
      "title": "How to Configure Redis on WordPress",
      "url": "https://example.com/configure-redis-wordpress/",
      "thumbnail_url": "https://example.com/wp-content/uploads/redis-cover.jpg",
      "excerpt": "A short plain-text excerpt from the post.",
      "author_name": "Sakil",
      "published_at": "2026-04-14T09:00:00+00:00",
      "categories": ["Performance", "Hosting"],
      "tags": ["redis", "caching", "server"]
    }

    Custom fields can be added to this payload using the get_post_meta() function in code, or via post meta merge tags in the workflow builder. If your destination service requires HMAC signature verification for security, that is a Pro feature covered in the incoming webhook receiver documentation.

    Most webhook tutorials give you a snippet that works in development and fails quietly in production. The gap is always retry logic and observability, not the initial send.

    Also Worth Knowing About

    Pollify is wpRigel’s poll, survey and quiz plugin for WordPress. It builds polls as native Gutenberg blocks, so there are no shortcodes to paste and no separate admin interface to learn. If you are publishing content and want to gather reader feedback inline, it fits into the same post-publish workflow.

    Commandify is a command palette for the WordPress admin. Press Cmd or Ctrl plus K to jump anywhere in the dashboard, search posts, users and products, and run admin actions without navigating menus. It is the only WordPress command palette with real WooCommerce order, product and customer commands built in.

    Next Steps

    If you are starting with the code path, copy the snippet above, replace the endpoint URL, and publish a test post on a staging site first. If you need retry logic, failure notifications or the ability to test without publishing real content, the free plugin is the faster path and costs nothing to try. The step-by-step workflow builder guide covers the full setup from first trigger to active workflow in one place.

    Try Krom Automation free on WordPress.org

    Frequently Asked Questions

    Why is my WordPress publish webhook firing multiple times for the same post?

    The most common cause is using the publish_post hook without checking whether the post was already published. Every time the post is updated after going live, that hook fires again.

    Switch to transition_post_status and add an $old_status === 'publish' guard to skip anything that was already in the published state. A second cause is autosave or revision saves triggering the same action, which a transient lock keyed to the post ID will prevent.

    How do I send a webhook only for specific post types or categories?

    In the code path, add a $post->post_type check inside the callback and return early if the type does not match. For category filtering, use wp_get_post_categories() and check whether the returned term IDs include your target. In the workflow builder, the Post Published trigger has a post type selector and a category filter field built into the trigger configuration panel, so no code is needed.

    What happens to the webhook if the receiving endpoint is down?

    With a plain PHP snippet and blocking => false, the request is sent and forgotten. If the endpoint returns an error or is unreachable, the event is lost with no log.

    With a queued workflow plugin, the failed attempt is logged with the response code, automatic retry runs with backoff, and an email notification is sent after a configurable number of failures. For any integration where losing the event matters, the queued approach is the correct one.

    How do I add the post thumbnail URL and custom fields to the webhook payload?

    In the code path, use get_the_post_thumbnail_url( $post, 'full' ) for the thumbnail and get_post_meta( $post->ID, 'your_field_key', true ) for custom fields, then include both in the array passed to wp_json_encode(). In the workflow builder, thumbnail URL and post meta values are available as merge tags. Click the {} merge tags button in the HTTP Request body field to browse all available variables for the Post Published trigger.

    Can I test a WordPress publish webhook without publishing a real post?

    With the code path, no. You must publish a real post or temporarily hook into a different action for testing.

    With the workflow plugin, the built-in simulator runs the full workflow against real post data and shows the resolved payload and simulated action output without firing the HTTP request or touching any external service. This means you can verify the payload structure before the workflow goes active.

    The wpRigel Team

    November 9, 2026
    Krom Automation
  • How to Email Subscribers When a New WordPress Post Is Published

    You can automatically email subscribers when a new WordPress post publishes by using a workflow automation plugin to connect the Post Published trigger to a Send Email action. The whole setup takes under 15 minutes and requires no code. The harder problem, which almost no tutorial covers, is making sure those notification emails actually reach the inbox instead of the spam folder.

    This tutorial walks through the complete setup: collecting subscribers, building the notification workflow, customising the email, and verifying deliverability. We tested this on a self-hosted WordPress 6.5 site running PHP 8.2. The steps below reflect exactly what you will see on screen.

    Before diving into the steps, one orientation note. This tutorial focuses on self-hosted WordPress.org sites.

    WordPress.com has a built-in follower notification system under Settings Discussion that works without any plugin. If you are on WordPress.com, that is the place to start, as documented in the WordPress.org documentation.

    What You Need Before Starting

    • A self-hosted WordPress site running WordPress 6.2 or higher and PHP 7.4 or higher.
    • A way to collect subscriber emails. A contact form, a subscription block, or a user registration flow all work. The workflow listens for whichever event you choose.
    • An SMTP plugin or transactional email service. WordPress’s native wp_mail function uses PHP mail, which most hosts do not authenticate properly. Without SMTP, your notification emails will land in spam at a rate that makes the whole feature pointless. More on this in the deliverability section below.
    • Krom Automation installed and active. The free version on the WordPress.org plugin directory includes the Post Published trigger and Send Email action you need for this exact workflow.

    If you have not installed the plugin yet, follow the installation guide first. It takes about two minutes.

    Step 1: Decide How You Are Collecting Subscribers

    Your notification workflow needs a list of people to email. How that list is built determines which approach works best for you.

    The three most common patterns on WordPress are:

    • Registered WordPress users. Anyone who has created an account on your site. The Send Email action can target all users or a specific role. No separate list management needed.
    • Form submissions stored as user meta or in a custom table. A subscriber enters their email via a form, and your workflow stores that email somewhere queryable. This is the most flexible pattern but requires a bit more setup.
    • An email marketing platform list. Subscribers sign up via Mailchimp, MailerLite, ConvertKit or similar. Your post notification goes out through that platform, not through WordPress directly. This is the most deliverability-safe option because those platforms handle authentication on your behalf.

    For this tutorial we focus on the native WordPress approach: emailing registered users when a post publishes. If you want to sync subscribers to an external list first, the Mailchimp integration documentation and the MailerLite integration documentation cover that path in detail.

    Step 2: Build the Post Notification Workflow

    Go to WordPress Admin Krom Automation Workflows and click New Workflow. You will land on the visual canvas. The canvas uses a drag-and-drop interface where every workflow starts with a trigger node on the left and connects to action nodes on the right.

    2a. Set the Trigger

    Click the trigger node and choose Post Published from the trigger list. You will see a configuration panel slide in on the right side of the screen. Set the following:

    • Post Type: Post (or whichever post type you publish to).
    • Category filter: Leave blank to fire on every new post, or select one or more categories if you only want to notify subscribers about specific topics. A site publishing in five categories but only wanting to alert subscribers about one of them should set this filter here rather than adding conditional logic later.
    • Status transition: The trigger fires when post status changes to “publish”. This means scheduled posts that go live automatically will also trigger the workflow, which is usually what you want.

    For a full reference of what this trigger passes downstream, including all available merge tags, see the free triggers reference.

    2b. Add the Send Email Action

    Click the plus icon after the trigger node and add a Send Email action. The configuration panel shows four fields:

    • To: Enter the email addresses of your subscribers, or use a merge tag that resolves to a list. For registered users with the Subscriber role, you can build a simple query. For small lists under 500 addresses, entering a distribution list address here is the most practical approach.
    • Subject: Use merge tags to make it dynamic. A subject like New post: {{post_title}} takes two seconds to write and performs meaningfully better than a generic “New post from our blog”.
    • Body: Write the email body here. Include {{post_title}}, {{post_excerpt}} and {{post_url}} at minimum. These pull the live post data at the moment the workflow executes.
    • From name and From email: Set these explicitly. Leaving them as WordPress defaults means the email comes from “WordPress” at your domain, which looks unprofessional and hurts open rates.

    Merge tags are covered in full in the merge tags documentation. Every post field you can imagine is available: title, excerpt, URL, featured image URL, author name, publish date and more.

    A subject line with the actual post title gets clicked. A subject line that says “New post from our blog” gets ignored. The merge tag takes two seconds to add.

    2c. Configure Run Once Per Post

    Open the workflow settings panel and enable Run Once Per Entity. This prevents the workflow from firing multiple times if a post is accidentally saved to draft and re-published.

    Without this setting, a post updated from draft to publish twice sends two notification emails to every subscriber. Enable it on every notification workflow.

    For a complete walkthrough of workflow settings including pausing, notes and import/export, see the workflow settings documentation.

    2d. Test Before Activating

    Use the built-in Workflow Simulator before switching the workflow live. The simulator runs the workflow in dry-run mode: it processes the trigger, evaluates conditions and steps through every action, but sends no actual emails and makes no database changes. You will see exactly what the email would contain, including which merge tags resolved and which did not.

    The simulator documentation shows you how to supply a test post ID so the dry run uses real data. Once every field looks correct, activate the workflow using the toggle at the top of the canvas.

    Step 3: Fix Deliverability (The Step Everyone Skips)

    This is the section that determines whether any of the above actually works. We have seen sites with a perfectly configured notification workflow where subscribers reported never receiving emails. Every single time, the root cause was deliverability, not the workflow itself.

    WordPress sends email via PHP’s mail() function by default. Most shared hosts do not configure DKIM or SPF records for mail sent this way, which means receiving mail servers treat it as suspicious. Gmail, Outlook and Apple Mail all apply aggressive spam filtering to unauthenticated email from web servers.

    The Deliverability Checklist

    Work through these in order. Skipping ahead to item 3 without completing item 1 wastes time, because unauthenticated mail gets filtered regardless of content quality.

    1. Add SPF and DKIM records to your domain’s DNS. SPF tells receiving servers which IP addresses are allowed to send email for your domain. DKIM adds a cryptographic signature to each email that proves it was not tampered with in transit. Both records live in your domain’s DNS panel. Your hosting provider or email provider should document exactly what values to add. Without these two records, skip the rest of this list and fix this first.
    2. Install an SMTP plugin and connect a transactional email service. Services like Amazon SES, Postmark, Mailgun or SendGrid handle authentication correctly and maintain sending reputation over time. Free tiers on most of these services cover thousands of emails per month, which is enough for most WordPress blogs. The SMTP plugin (WP Mail SMTP is widely used, as is FluentSMTP) replaces the PHP mail function with an authenticated API call to your chosen service.
    3. Set a consistent From address that matches your domain. Sending from a Gmail or Yahoo address while your site lives at yourdomain.com is an instant spam signal. The From email in your workflow’s Send Email action must use your own domain.
    4. Add a plain-text version of the email. HTML-only emails score worse on spam filters. Most SMTP plugins handle this automatically if you configure them to, but verify it in your email testing tool.
    5. Test deliverability before your first real send. Mail-tester.com gives your email a deliverability score out of 10 and shows exactly which checks passed or failed. Run a test email through it before activating your workflow. Aim for 9 or above. A score below 7 means subscribers on Gmail will likely never see your notifications.

    The WordPress documentation on plugin basics does not cover email deliverability because it is an infrastructure concern, not a WordPress concern. That is precisely why every plugin tutorial skips it and why subscribers end up not receiving emails.

    A perfectly configured workflow sending to spam is indistinguishable from a broken workflow. Fix authentication before you blame the plugin.

    Step 4: Handle Category-Specific Notifications

    Some sites publish across multiple topics and want to let subscribers opt in to specific categories. A reader interested in tutorials should not receive every product announcement. This is a filtering problem, and there are two ways to solve it.

    Option A: Separate workflows per category. Build one workflow for each category with the category filter set on the Post Published trigger. This is the simplest approach and requires no conditional logic. The downside is that managing 8 categories means 8 workflows to maintain.

    Option B: One workflow with conditional branching. Use a single Post Published trigger and add Yes/No branches based on the post’s category. Each branch routes to a Send Email action targeting the appropriate subscriber segment.

    This is cleaner at scale but requires understanding how conditions work. The conditions and branching documentation walks through the exact logic.

    Either option works. Choose Option A if you have fewer than 5 categories and a small team. Choose Option B if you are building this for a large publication where workflow sprawl becomes a maintenance burden.

    Step 5: Add a Delay for Scheduled Posts

    If you schedule posts to go live at a specific time, consider adding a short delay between the Post Published trigger and the Send Email action. A 5-minute delay gives you a window to catch a typo or pull the post back before every subscriber has already received the notification.

    Add a Delay node between the trigger and the action on the canvas. Set it to 5 minutes.

    If you need to cancel the send, deactivate the workflow before the delay expires. The delays and scheduling documentation covers how queued actions behave when a workflow is paused mid-execution.

    What to Do When Subscribers Do Not Receive the Email

    If the workflow ran but subscribers report not receiving anything, work through this in order:

    • Check the execution log first. Go to Krom Automation Logs and find the execution for the post in question. The log shows every step with a pass or fail status. If the Send Email step shows a failure, the error message will identify whether the problem is authentication, a bad recipient address, or a timeout from your SMTP provider.
    • Check the spam folder. Ask a subscriber to check spam before assuming the email was never sent. If it is landing in spam, the problem is deliverability (see Step 3), not the workflow.
    • Verify the From address. An unrecognised From address is the fastest route to spam. Check that the From email in your workflow matches the domain you authenticated in DNS.
    • Check WP-Cron. Krom Automation runs actions via Action Scheduler, which depends on WP-Cron. On very low traffic sites, WP-Cron can fire late if no page loads occur during the scheduled window. Configure a real server cron job to call wp-cron.php on a fixed schedule (every minute is standard). Your host’s control panel or a system cron entry handles this. The WordPress Cron documentation explains the difference between WP-Cron and system cron.
    • Check the Run Once setting. If the workflow is set to Run Once Per Entity and the post was previously published (even briefly), the workflow will not fire again. This protects against duplicates but can confuse troubleshooting. The execution log will show a “skipped” entry with the reason.

    Connecting to an External Email List

    The native Send Email action works well for smaller lists and internal notifications. For lists above roughly 2,000 subscribers, or for sites that want subscriber management features like unsubscribe handling, bounce processing and open rate tracking, connecting to an email marketing platform is the right choice.

    The workflow structure changes slightly. Instead of a Send Email action, you trigger a campaign in your external platform by adding or tagging a contact when a post publishes. The platform then handles delivery to your full list using its own authenticated infrastructure.

    Documentation for the platforms we support:

    • Mailchimp integration: subscribe, tag, and sync WordPress users automatically.
    • ConvertKit integration: subscribers, tags, sequences, and forms.
    • MailerLite integration: subscribe, unsubscribe, and manage groups.
    • FluentCRM integration: contacts, tags, and lists for teams running CRM inside WordPress.

    These integrations are Pro features. The free plugin handles Send Email natively with no external platform required.

    Past 2,000 subscribers, managing bounces and unsubscribes inside WordPress becomes a part-time job. An external platform earns its cost at that point.

    What This Workflow Looks Like in Practice

    Here is the complete workflow structure for a site that publishes tutorials and wants to email all registered subscribers within 5 minutes of each new post going live:

    Node Type Configuration Why it matters
    1 Trigger: Post Published Post type: Post, Category: Tutorials Fires only when a tutorial publishes, not every post type
    2 Delay 5 minutes Gives a window to cancel if the wrong post goes live
    3 Action: Send Email To: subscriber list, Subject: New tutorial: {{post_title}} Dynamic subject increases open rate versus generic subject

    Should You Build This Yourself or Use a Dedicated Newsletter Plugin?

    This is the honest trade-off table most tutorials do not include. The right answer depends on your list size and what you value.

    Factor Workflow automation approach Dedicated newsletter plugin
    Setup time Under 15 minutes for a simple notification 30 to 60 minutes including list import and template setup
    Subscriber management Manual or via user roles, no built-in unsubscribe UI Built-in subscribe/unsubscribe, list segmentation, GDPR tools
    Bounce and complaint handling Depends on your SMTP provider’s dashboard Automatic bounce and complaint processing
    Open and click tracking Not included in the native Send Email action Included in most newsletter plugins
    Best for list size Under 500 subscribers or internal team notifications 500 or more, or any list with public signup
    Works alongside other automations Yes, the same workflow engine handles all site events Depends on the plugin’s integration capabilities

    For sites where the goal is a simple “subscribers get an email when a post goes live” and the list is small, the automation approach is faster and adds no extra plugin to maintain. For sites building a real newsletter operation with segmentation and analytics, a dedicated newsletter plugin or external platform is the more sustainable choice, and the automation layer connects the two.

    Other Tools Worth Knowing About

    Pollify is wpRigel’s poll, survey and quiz plugin. It is built as native Gutenberg blocks, which means creating a poll inside a post works exactly like adding a paragraph.

    No shortcodes to paste, no separate interface to configure. If you are sending post notifications to subscribers, embedding a quick poll in those posts is a natural way to drive engagement back to the site.

    Commandify is a command palette for the WordPress admin. Press Cmd or Ctrl plus K and you can jump to any screen, search any content, or run admin actions without navigating menus.

    It is the only WordPress command palette with real WooCommerce order, product and customer commands built in. For teams managing a lot of content, it cuts the time spent clicking around the backend considerably.

    Next Steps

    The workflow itself is straightforward. The two things that determine whether it actually works are deliverability configuration (Step 3 above) and choosing the right approach for your list size (the trade-off table above). If you are starting fresh, complete the DNS authentication steps before activating the workflow.

    If you are troubleshooting an existing setup, start with the execution log in Krom Automation and check mail-tester.com before changing anything else. For a broader look at what automation can handle on a WordPress site, the overview of how Krom Automation works is a useful next read.

    Try Krom Automation free on WordPress.org

    Frequently Asked Questions

    Why are my subscriber notification emails going to spam?

    The most common cause is unauthenticated email. WordPress sends via PHP mail by default, which most hosts do not sign with DKIM or list in an SPF record.

    Install an SMTP plugin, connect a transactional email service, and verify your DNS records. Test your setup at mail-tester.com before activating the workflow.

    Can I send post notifications to registered WordPress users instead of an external list?

    Yes. The Send Email action lets you specify recipient addresses directly, including addresses you retrieve from registered users.

    For small sites where all subscribers have WordPress accounts, this is the simplest approach. For public subscriber lists, you need a form-based signup flow and a way to store those email addresses.

    How do I filter notifications so subscribers only get emails for specific categories?

    Set the Category filter on the Post Published trigger. The trigger only fires when a post in the selected category publishes.

    For multiple subscriber segments with different category preferences, either build separate workflows per category or use conditional branching inside a single workflow. The conditions and branching documentation covers the branching approach.

    Will the workflow fire if I schedule a post to publish automatically at a future time?

    Yes. The Post Published trigger fires whenever a post’s status transitions to “publish”, whether that happens immediately or via a scheduled publish. If you add a 5-minute delay node after the trigger, you have a short window to cancel the email send by deactivating the workflow before the delay expires.

    Does this work for custom post types, not just standard posts?

    Yes. When configuring the Post Published trigger, the Post Type field includes all public post types registered on your site. Select the custom post type you want to monitor and the trigger behaves identically to a standard post trigger.

    The wpRigel Team

    November 6, 2026
    Krom Automation, Marketing
  • How to Send a Coupon After a Customer’s First WooCommerce Order

    WooCommerce has no native trigger for a customer’s first order, so you need a workflow plugin to detect it and send the coupon automatically. The setup takes under 15 minutes and works without writing any code.

    This tutorial covers the complete workflow: detecting whether an order is genuinely a first purchase, generating a coupon, sending it by email, and preventing it from being shared or used by someone else. We also cover a lightweight developer hook at the end for shops that want zero extra plugins.

    Before we get into the steps, two decisions shape everything else: when to send (immediately or delayed) and unique versus generic codes. A generic code like WELCOME10 is easy to share and leaks across forums within days. A unique, single-use code tied to the customer’s email is worth the extra setup time.

    Does WooCommerce Handle This Natively?

    No. The WooCommerce core documentation covers coupons and email templates, but there is no built-in condition for “this customer has zero previous orders.” Every approach requires either a plugin or custom code.

    The core “Order Completed” email does let you attach a static coupon code as text, but it fires on every order, not just the first. That means a customer on their tenth purchase would still receive a first-order coupon if you configure it that way.

    A generic coupon code shared in a Facebook group costs you full margin on every order it touches. A unique single-use code costs you margin once, on the customer it was meant for.

    What You Need Before You Start

    • WooCommerce installed and running with at least one completed order to test against
    • A workflow plugin that supports a first-order condition (covered below)
    • A coupon action that can create a unique code per customer, not just insert a static string
    • An email action that can embed that generated coupon code into the message body using merge tags
    • A test customer account with zero previous orders, so you can verify the condition fires correctly

    The WooCommerce coupon documentation explains usage restrictions you can set at the coupon level, including email restriction. We will use that in Step 4.

    Step-by-Step: Build the Workflow

    Step 1. Install and activate the plugin

    Install Krom Automation from the WordPress.org plugin directory through Plugins Add New. Activate it.

    You will see a new Krom Automation menu item in your WordPress admin. No licence key is needed for the free version.

    Once active, go to Krom Automation Workflows and click New Workflow. You will land on the visual canvas. If this is your first workflow, the step-by-step workflow guide in the documentation covers canvas navigation in detail.

    Step 2. Set the trigger to Order Completed

    Click the trigger node on the canvas and choose Order Completed from the WooCommerce section. This fires every time an order moves to the Completed status, which is what you want as the entry point. You can see a full list of available triggers in the free triggers reference.

    At this stage the workflow fires on every completed order. The next step narrows it to first-time customers only.

    Step 3. Add a condition to check order count

    Add a Condition node after the trigger. Set it to check whether the customer’s total order count equals 1.

    The Yes path continues to the coupon creation. The No path does nothing (leave it empty or connect it to a Stop node).

    This is the critical gate. Without it, every customer who completes any order receives the coupon. The conditions and branching documentation shows the exact fields and operators available for this check.

    One important note: “Order Completed” fires after payment, not at checkout submission. That means the order count at the moment the trigger fires will already include the current order. So “equals 1” correctly identifies a customer whose very first order just completed.

    Step 4. Create the coupon

    On the Yes path, add a Create Coupon action. Configure it as follows:

    • Discount type: Percentage or fixed, your choice. We use 15% as a worked example.
    • Coupon code: Use a merge tag to generate a unique code per customer, for example WELCOME-{{order.id}} or a random string pattern. The merge tags documentation lists every available variable.
    • Usage limit: Set to 1. This ensures the code can only be redeemed once, by anyone.
    • Allowed emails: Add {{customer.email}} as a merge tag. WooCommerce will reject the coupon if the email at checkout does not match, which prevents sharing.
    • Expiry date: Set to 30 days from now. A deadline increases redemption rates. Without one, customers save the code and forget it.
    • Minimum spend: Optional. Setting a floor (say $30) protects margin on small repeat orders.

    Step 5. Add a delay (optional but recommended)

    Send the coupon immediately and it arrives inside the order confirmation email window, where it competes for attention. A delay of 2 to 3 days lets the product arrive first, so the coupon lands when the customer is thinking about their next purchase rather than waiting for the current one.

    Add a Delay node between the Create Coupon action and the Send Email action. Set it to 2 days. The delays and scheduling documentation covers all available units including hours, days and weeks.

    Step 6. Send the email

    Add a Send Email action. Use merge tags to personalise the subject and body:

    • To: {{customer.email}}
    • Subject: Your exclusive discount, {{customer.first_name}}
    • Body: Write a short message and embed {{coupon.code}} to display the unique code the previous action generated

    Keep the email to three short paragraphs. State the discount amount, the expiry date, and the minimum spend if you set one. Ambiguity here costs you redemptions.

    Step 7. Test before activating

    Use the workflow simulator to run a dry test with no side effects before you go live. The simulator documentation explains how to pass in a sample order and inspect what each node would do. Check that the condition resolves to Yes for a customer with one order and No for a customer with two or more.

    When the test passes, enable the workflow and place a real test order using a fresh customer account. Confirm the coupon appears in WooCommerce Coupons with the correct email restriction, and that the email arrives on schedule.

    Running the simulator before activating takes two minutes. Discovering the condition was inverted after 400 real orders have fired takes considerably longer to unpick.

    What the Condition Check Actually Prevents

    The order-count condition does one thing that email restriction alone does not: it stops the workflow from firing at all for repeat customers. Email restriction at the coupon level stops redemption, but the email still sends, which looks like a mistake to the customer. Catching it in the workflow condition means no email, no coupon, no confusion.

    Three scenarios worth testing explicitly:

    • Guest checkout, then account creation: The order count is attached to the email address. If the customer checks out as a guest and then creates an account with the same email, WooCommerce links the history. The condition will count the guest order.
    • Refunded first order: A refund does not remove the order from the count. If this matters for your store, add a second condition checking order status is not Refunded.
    • Multiple orders on the same day: On very high-volume flash sales, two orders can complete within seconds. The run-once-per-entity setting prevents the workflow from firing twice for the same customer. Enable it in workflow settings.

    Timing: When Should the Coupon Email Arrive?

    Send timingBest forRisk
    Immediately after orderDigital products, instant deliveryLost in the confirmation email batch
    2 to 3 days after orderPhysical goods with standard shippingRequires a delay node and reliable WP-Cron
    After order status changes to DeliveredShops using shipping tracking pluginsRequires a Pro trigger tied to status change

    The 2 to 3 day delay is the most common setup we see for physical goods. The customer has the product in hand, the purchase satisfaction is fresh, and the coupon arrives before competing stores have a chance to retarget them. For digital products, immediate delivery makes more sense because there is no shipping window to work with.

    One caveat on delays: delays run through WordPress Cron. On low-traffic sites that go hours between visits, WP-Cron fires late.

    If your store gets fewer than a few hundred visits a day, configure a real server cron job to call wp-cron.php on a schedule. The WordPress developer documentation on WP-Cron covers this setup.

    Cost Comparison: Which Approach Fits Your Setup

    ApproachUpfront costYear 1 costUnique codesVisual builder
    Krom Automation free$0$0Yes, via merge tagsYes
    Krom Automation Pro (1 site)$69/year$69YesYes, with email builder
    AutomateWooIncluded with WooCommerce paid plansVaries by planYesNo, list-based rules
    Custom code (developer)Developer time (est. 1 to 3 hours)Maintenance burdenRequires extra codeNo

    The free tier covers everything in this tutorial. Pro adds the visual email builder for designing the coupon email without touching HTML, plus a Schedule trigger and an incoming webhook receiver if you want to extend the workflow further.

    The Developer Shortcut: No Plugin Required

    If you manage your own site and want zero additional plugins, this hook handles the detection. Add it to your theme’s functions.php or a site-specific plugin:

    add_action( 'woocommerce_order_status_completed', function( $order_id ) {
        $order    = wc_get_order( $order_id );
        $customer = new WC_Customer( $order->get_customer_id() );
    
        if ( $customer->get_order_count() !== 1 ) {
            return;
        }
    
        // Create coupon
        $coupon_code = 'WELCOME-' . strtoupper( wp_generate_password( 8, false ) );
        $coupon      = new WC_Coupon();
        $coupon->set_code( $coupon_code );
        $coupon->set_discount_type( 'percent' );
        $coupon->set_amount( 15 );
        $coupon->set_usage_limit( 1 );
        $coupon->set_email_restrictions( [ $order->get_billing_email() ] );
        $coupon->set_date_expires( strtotime( '+30 days' ) );
        $coupon->save();
    
        // Send email
        WC()->mailer()->emails['WC_Email_Customer_Processing_Order']
            ->trigger( $order_id ); // Replace with a custom email class for production
    } );

    This is a starting point, not production-ready code. The email line needs replacing with a custom WC_Email class that includes the coupon code in the body.

    If that scope is comfortable for your team, this route avoids a plugin entirely. If it is not, the visual workflow approach is faster and easier to maintain.

    What None of the Tutorials Tell You

    Most guides stop at “configure the plugin and send the email.” Three things that actually affect whether the coupon converts into a second purchase:

    • Subject line specificity wins. “Here’s your discount” gets ignored. “Your 15% off expires in 30 days, [Name]” tells the customer exactly what they have and when it expires. That specificity drives opens.
    • The minimum spend floor matters more than the discount percentage. A 10% coupon with a $50 minimum on a store whose average order value is $45 will almost never redeem. The floor needs to sit below the average order value or you are optimising for a transaction that rarely happens.
    • Coupon visibility on the thank-you page doubles as a channel. Email is not the only delivery point. Adding the coupon code to the WooCommerce thank-you page via a custom hook means customers see it immediately, before email even arrives. The delay approach and the thank-you page approach are not mutually exclusive.

    The minimum spend floor is the detail most store owners skip. Set it above your average order value and the coupon looks generous but almost never redeems.

    Other Tools Worth Knowing About

    If you are running a WooCommerce store alongside other automation needs, two other wpRigel tools are worth a look. Commandify is a command palette for the WordPress admin.

    Press Cmd or Ctrl plus K to search orders, customers and products without clicking through menus. It is the only command palette with real WooCommerce order and customer management built in, which makes post-purchase admin significantly faster.

    Pollify builds polls, surveys and quizzes as native Gutenberg blocks. If you want to collect feedback from customers after their first purchase, a post-order survey embedded on the thank-you page or in the follow-up email is a natural companion to the coupon workflow.

    If your store runs WooCommerce Subscriptions alongside standard orders, the WooCommerce Subscriptions integration documentation shows how subscription-specific triggers work alongside the standard Order Completed trigger covered here.

    Frequently Asked Questions

    Does the Order Completed trigger fire for guest checkouts?

    Yes. The trigger fires regardless of whether the customer has an account. The order count check uses the billing email to look up history, so guest orders are included in the count as long as the same email address was used.

    How do I make sure the coupon can only be used by the original customer?

    Set the Allowed Emails field in the Create Coupon action to the customer’s email address using the {{customer.email}} merge tag. WooCommerce will block any checkout that uses a different email address. Combined with a usage limit of 1, the code is effectively single-use and non-transferable.

    What happens if the customer’s first order gets refunded?

    The order remains in the count even after a refund, so the workflow fires as expected. If you want to withhold the coupon for refunded first orders, add a second condition checking that the order status is not Refunded before the Create Coupon action runs.

    Can I send the coupon on the thank-you page instead of by email?

    The workflow approach described here sends by email. Displaying the coupon on the thank-you page requires a custom hook using woocommerce_thankyou or a page builder that supports order data. You can run both in parallel: create the coupon in the workflow, display it immediately on the thank-you page via a hook, and then send the email reminder 2 days later.

    Will this work if I use a custom order status instead of Completed?

    The Order Completed trigger fires specifically on the WooCommerce “Completed” status. If your store uses a custom status as the final step, use the Post Status Changed trigger instead and filter to your custom status. The order count condition logic stays the same.

    Next Steps

    The workflow in this tutorial takes under 15 minutes to build, but the decisions around discount amount, timing and minimum spend have a bigger effect on your second-purchase rate than the technical setup does. Start with a 15% discount, a 30-day expiry and a minimum spend set $5 below your average order value.

    Run it for 60 days, check how many coupons were created versus redeemed in the execution logs, and adjust from there. For more automation ideas once this workflow is live, the article on changing a user role after a WooCommerce purchase shows how to combine the same trigger with a different action to unlock member pricing automatically.

    Try Krom Automation free on WordPress.org

    The wpRigel Team

    November 4, 2026
    Krom Automation, WooCommerce
  • How to Collect Open-Ended Feedback in WordPress

    How to Collect Open-Ended Feedback in WordPress

    An open-ended poll asks a question that people answer in their own words instead of picking from options. In WordPress you can collect this with a feedback form or a dedicated block; Pollify Pro‘s Engagement block shows a short question as a popup or a floating Feedback button and stores every answer in your dashboard.

    Multiple-choice polls tell you what people think. Open answers tell you why, and often surface problems you would never have thought to ask about.

    When to Ask an Open Question

    • After a number: “What is the main reason for your score?” turns a rating into something you can act on.
    • When you do not know the options: “What almost stopped you from buying today?” finds objections you had not considered.
    • On help content: “Did this article solve your problem? If not, what’s missing?”
    • For ideas: “What should we write about next?” or “What feature would you add?”

    How to Collect Open-Text Feedback With the Engagement Block

    1. With Pollify Pro active, open the page or post where you want feedback.
    2. Click +, search for Engagement and add the block.
    3. In General settings, give it a Title such as “Pricing page feedback”.
    4. Choose a Display mode: Threshold popup (appears on a set visit) or Persistent button (a floating Feedback button visitors can open anytime).
    5. For the popup, set the View threshold. It shows when the visit count matches exactly, so 3 means the third visit. Pick how it animates in.
    6. For the button, pick the corner and the button text, and choose whether to hide it after someone submits.
    7. In Response settings, turn on Allow one response per computer and write your Thank-you message.
    8. Type your question in the canvas and click Update.
    Adding the Pollify Engagement block in the WordPress editor
    Pollify Engagement block response settings with one response per computer and thank-you message

    What Visitors See

    In popup mode, the question appears on the visit you chose. In button mode, a small Feedback button sits in the corner, and clicking it opens the question. After answering, visitors see your thank-you message.

    Pollify Engagement feedback popup on the front end of a WordPress site

    Reading the Answers

    All responses are collected in your Pollify dashboard, with the full text of each answer. Pollify Pro can also export them to a spreadsheet for sorting.

    Pollify Engagement feedback results in the WordPress dashboard

    Turning answers into actions

    1. Read every answer once, without judging.
    2. Give each one a short tag, such as “price”, “shipping” or “confusing setup”.
    3. Count the tags. The biggest group is your first fix.
    4. Save one or two exact quotes per tag. Real words convince a team faster than a summary.

    Writing Good Open Questions

    • Ask one thing. “What would you improve?” beats “What do you like and dislike about our pricing and features?”
    • Be specific. “What almost stopped you from signing up?” gets better answers than “Any feedback?”
    • Keep it neutral. “How was checkout?” rather than “How easy was our simple checkout?”
    • Ask at the right moment. On the page the question is about, after the visitor has had time to form an opinion.

    Combine Open Questions With a Rating

    The strongest setup pairs a number with a reason. An NPS survey does exactly that: a 0 to 10 score followed by an optional comment. See how to run an NPS survey in WordPress.

    On a Budget?

    Without Pro, you can still collect written feedback with a simple contact form on a “Feedback” page, or by asking a question at the end of your posts and reading the comments. You lose the popup timing and the central dashboard, but it is a fine way to start.

    Frequently Asked Questions

    Is the Engagement block in Pollify Free?

    No. It is part of Pollify Pro. The free version covers multiple-choice polls.

    Will the popup annoy visitors?

    It only appears on the visit number you choose, not on every page view, and the button mode waits for visitors to open it.

    Can I export the answers?

    Yes, with Pollify Pro. See how to export poll results.

    Next Steps

    Pick the page where people hesitate most, often pricing or checkout, and ask one specific question there. Read the answers weekly for a month before you change anything.

    See Pollify Pro plans

    The wpRigel Team

    November 4, 2026
    Pollify
  • How to Change a User Role After a WooCommerce Purchase

    You can change a WordPress user role automatically when a WooCommerce order reaches “Completed” status, either with a visual workflow builder that takes about five minutes to configure, or with a code snippet targeting the woocommerce_order_status_completed hook. Neither approach requires a dedicated membership plugin.

    This tutorial covers the full picture: assigning a role tied to a specific product, handling guest purchasers who have no WordPress account yet, and revoking a role when an order is refunded or cancelled. Those last two scenarios are the ones most guides skip, and they are where broken setups cause the most support tickets.

    Work through the options in the order they appear here. The no-code path takes less time and gives you execution logs from day one. The code path gives you full control with zero additional plugins, but requires a place to store snippets safely.

    What You Are Actually Trying to Solve

    The motivating use case is almost always one of these three things:

    • Membership access: a customer buys a “Premium Member” product and should move from the default customer role to a custom premium_member role that unlocks restricted content.
    • VIP tier: a customer spends over a threshold (say $200 in a single order) and earns a vip role that unlocks a wholesale price list.
    • Course or community access: a customer buys a course bundle and should be elevated to a role that a LearnDash group or BuddyBoss community recognises as enrolled.

    All three follow the same logic: an order event fires, you check a condition, and you call WordPress’s wp_update_user() or WP_User::set_role() with a new role slug. The difference is which condition you check and what happens when the purchase is reversed.

    A role change with no revocation path is a promise you will eventually break. Build the cancellation branch at the same time you build the assignment branch.

    Option A: No-Code Workflow (Recommended Starting Point)

    Krom Automation’s free tier includes both the Order Completed trigger and the Change User Role action, along with conditional branching to filter by product ID. Installation takes under two minutes from the WordPress.org plugin directory. If you want to understand how the builder works before you start, the triggers, actions, and workflows overview explains the mental model clearly.

    Step 1: Install and Open the Workflow Builder

    Go to Plugins Add New, search for “Krom Automation”, install and activate. A new Krom Automation menu appears in your sidebar.

    Click it, then click New Workflow. You will land on a drag-and-drop canvas with an empty start node.

    Step 2: Set the Trigger to “Order Completed”

    Click the start node and choose WooCommerce Order Completed from the trigger panel on the right. This fires once per order, after WooCommerce moves the order status to completed.

    It does not fire for processing or pending, which matters if your product is digital and auto-completes immediately. Refer to the free triggers reference for the exact data fields each trigger exposes.

    Step 3: Add a Condition to Filter by Product

    Click the + button below the trigger node and add a Condition block. Set it to check whether Order Line Items Product ID contains your target product’s ID. The canvas splits into a Yes path and a No path.

    Everything on the Yes path runs only for orders that contain that product. The conditions and branching documentation shows every available operator, including “contains any of” for matching multiple product IDs at once.

    Step 4: Add the “Change User Role” Action

    On the Yes path, add an action node. Choose User Change User Role. Set the User field to the merge tag {{order.customer_id}} and the New Role field to your target role slug, for example premium_member.

    Save. The merge tags documentation lists every dynamic variable available from the Order Completed trigger.

    Step 5: Test Before Going Live

    Click the Simulate button in the top toolbar. The simulator runs the workflow with a real order ID you supply, shows you what each step would do, and exits without writing any changes to the database.

    This dry-run capability catches configuration mistakes before they touch live user data. The workflow simulator documentation explains how to supply test data for each trigger type.

    Once the simulation shows the correct role slug in the action output, toggle the workflow to Active and place a test order. Check the execution log under Krom Automation Logs to confirm the action ran and the user record updated.

    Option B: Code Snippet

    If you prefer not to add a plugin, the following snippet handles the same assignment. Add it to a site-specific plugin or use a snippet manager like WPCode. Never paste custom PHP into functions.php on a theme you did not build, because a theme update will erase it.

    add_action( 'woocommerce_order_status_completed', 'assign_role_on_product_purchase' );
    
    function assign_role_on_product_purchase( $order_id ) {
        $order      = wc_get_order( $order_id );
        $user_id    = $order->get_customer_id();
        $target_ids = array( 123, 456 ); // Replace with your product IDs
    
        if ( ! $user_id ) {
            return; // Guest checkout, see the guest section below
        }
    
        foreach ( $order->get_items() as $item ) {
            if ( in_array( $item->get_product_id(), $target_ids, true ) ) {
                $user = new WP_User( $user_id );
                $user->set_role( 'premium_member' );
                break;
            }
        }
    }
    

    Use set_role() not add_role() here. The set_role() method replaces the user’s primary role. The add_role() method stacks an additional role on top.

    Most membership setups want replacement, because a user with both customer and premium_member roles creates ambiguous capability checks. If your access control explicitly relies on multiple roles, use add_role() and document the decision.

    The WooCommerce developer docs confirm that order status transitions fire on the action hook named after the destination status, which is why woocommerce_order_status_completed is the correct hook and not woocommerce_payment_complete. The WordPress codex entry for WP_User::set_role() documents every accepted argument.

    The hook name tells you exactly when it fires. woocommerce_order_status_completed fires after the status transition, not after payment, and not at checkout submission.

    Filtering by Product Category Instead of Product ID

    If you sell products in a “Membership” category and want every product in that category to trigger the role change, swap the product ID check for a term check:

    • In the no-code workflow, change the condition to check Order Line Items Product Categories Contains and enter your category slug.
    • In the code snippet, replace in_array( $item->get_product_id(), $target_ids ) with has_term( 'membership', 'product_cat', $item->get_product_id() ).

    Category-based triggers are more maintainable at scale. Adding a new product to the category is enough to include it in the automation. There is no list of product IDs to update.

    Handling Guest Purchasers

    Every guide written about this topic assumes the buyer has a WordPress account. That assumption breaks the moment you allow guest checkout, which WooCommerce enables by default.

    When $order->get_customer_id() returns 0, the buyer has no user record. You have three realistic paths:

    • Force account creation at checkout: go to WooCommerce Settings Accounts and Privacy and enable “Allow customers to create an account during checkout” and “When creating an account, automatically generate a username and password.” WooCommerce creates the account before the order is placed, so get_customer_id() always returns a valid ID by the time your hook fires.
    • Create the account on order completion via code: call wc_create_new_customer( $order->get_billing_email() ) inside your hook when $user_id === 0, then link the order to the new user with $order->set_customer_id( $new_user_id ) and $order->save(). This works but requires careful error handling for duplicate email addresses.
    • Send an account creation email: send the guest a transactional email asking them to create an account. Apply the role on the user_register hook by storing the intended role in order meta and retrieving it on registration. This is the most complex path and only worth building if you cannot change the checkout flow.

    The simplest fix for most stores is the first option. Requiring an account at checkout adds one step for the buyer but eliminates the guest-to-role problem entirely. The WooCommerce documentation covers order management and customer account settings in detail.

    Role Revocation on Refund or Cancellation

    This is the scenario almost no tutorial covers, and it is the one that generates the most angry users. A customer gets refunded, keeps their premium role, and continues accessing content they are no longer paying for.

    To handle revocation, hook into order status changes that indicate a reversal:

    add_action( 'woocommerce_order_status_refunded', 'revoke_role_on_refund', 10, 1 );
    add_action( 'woocommerce_order_status_cancelled', 'revoke_role_on_refund', 10, 1 );
    
    function revoke_role_on_refund( $order_id ) {
        $order   = wc_get_order( $order_id );
        $user_id = $order->get_customer_id();
    
        if ( ! $user_id ) {
            return;
        }
    
        $target_ids = array( 123, 456 ); // Same product IDs as your assignment hook
        $has_target = false;
    
        foreach ( $order->get_items() as $item ) {
            if ( in_array( $item->get_product_id(), $target_ids, true ) ) {
                $has_target = true;
                break;
            }
        }
    
        if ( $has_target ) {
            $user = new WP_User( $user_id );
            $user->set_role( 'customer' ); // Revert to default WooCommerce role
        }
    }
    

    One important caveat: if a customer has multiple orders, reverting the role on one refund may remove access they earned through a separate valid purchase. Before calling set_role() in the revocation path, query the user’s other completed orders to confirm no other qualifying purchase exists. That extra check adds complexity, but skipping it causes false revocations.

    In the no-code workflow path, you build this as a second workflow with the Order Status Changed trigger, a condition checking for status equal to refunded or cancelled, and the same Change User Role action pointing back to customer. If you are running WooCommerce Subscriptions, the WooCommerce Subscriptions integration documentation covers subscription-specific status triggers including expired, cancelled, and on-hold.

    Triggering a Role Change Based on Order Total

    The VIP tier use case works by checking order total rather than product ID. In the no-code path, swap the product condition for Order Total Greater Than and enter your threshold. In code, replace the product ID check with:

    if ( (float) $order->get_total() >= 200 ) {
        $user = new WP_User( $user_id );
        $user->set_role( 'vip_customer' );
    }
    

    The threshold of $200 is illustrative. Set it to whatever your margins support. Note that this fires on every completed order, so a customer who places a large order once will keep the VIP role indefinitely unless you add a revocation rule tied to the role’s business logic, such as no qualifying order in the last 12 months.

    What This Approach Does Not Cover

    Being clear about the limits saves you a debugging session later:

    • Subscriptions with automatic renewal: WooCommerce Subscriptions creates renewal orders automatically. The role assignment hook fires on renewal if the renewal order reaches completed, which is usually what you want. But the revocation logic needs to hook into subscription-specific events like woocommerce_subscription_status_cancelled, not just order status changes.
    • Role expiry after a fixed period: neither approach here schedules a future revocation. For time-limited access you need a cron job or a scheduled workflow using the schedule trigger in Pro to check and revert roles after a set number of days.
    • Sites with zero traffic during off-hours: code snippet hooks fire in-process and are reliable. Workflow automation that uses delayed actions depends on WordPress Cron, which only fires when someone visits the site. On very low-traffic sites, configure a real server-side cron to keep WP-Cron reliable.
    • Multisite: WP_User::set_role() sets the role on the current site in the network. Cross-site role assignment requires explicitly switching blog context with switch_to_blog().

    Choosing Between the Two Approaches

    Situation Best approach Why
    Single product, no existing code setup No-code workflow Five minutes to configure, execution logs included, no PHP required
    Multiple products across multiple conditions No-code workflow with branching Visual canvas makes multi-condition logic readable at a glance
    Already managing custom snippets on the site Code snippet No additional plugin, logic lives with your other customisations
    Guest checkout is enabled and cannot be changed Code snippet Easier to add account-creation logic inline before role assignment
    Need role revocation on subscription cancellation No-code workflow + Subscriptions integration Subscription-specific triggers are not available via a simple order hook
    Agency managing 10 or more client sites No-code workflow, exported as JSON Workflow import/export lets you redeploy the same logic across sites in seconds

    Troubleshooting: Why Your Role Change Is Not Working

    Work through this list in order. The first item on the list accounts for roughly 60% of failed setups, so check it before anything else.

    • Order status is “Processing”, not “Completed”: digital products set to auto-complete will reach completed immediately. Physical products stay at processing until you manually complete them or a fulfilment plugin does it. If your hook is not firing, check the order status in WooCommerce Orders first.
    • Guest checkout returned user ID 0: add a check for $user_id === 0 and log or skip gracefully. Silently failing on guest orders is the most common source of “it works sometimes” reports.
    • The role slug does not exist: set_role() silently does nothing if the role slug is not registered. Confirm the slug with wp_roles()->get_names() in the WP-CLI or in a temporary debug line. Slugs are case-sensitive and use underscores, not hyphens, in most plugins.
    • Another plugin is reverting the role: some membership plugins reset user roles on every page load or login. Check for plugins like MemberPress, Paid Memberships Pro, or Restrict Content Pro that manage roles independently, and decide which system owns the role.
    • The hook fired but the product condition did not match: if you are using the code snippet, add a temporary error_log() call to output the product IDs in the order. Compare them against your $target_ids array. Variable products return a variation ID from get_product_id() on the line item; use get_parent_id() on the variation to get the parent product ID.

    Variable product line items return the variation ID, not the parent product ID. That single mismatch causes more silent failures than any other source in this workflow.

    What This Setup Pairs Well With

    Role assignment on purchase is rarely the only thing you want to happen when an order completes. Common additions to the same workflow include sending a welcome email through the visual email builder, tagging the contact in FluentCRM via the FluentCRM integration, or enrolling the customer in a LearnDash course via the LearnDash integration. All of these can live in the same workflow on the same canvas, triggered by the same Order Completed event.

    If you are sending post-purchase review requests alongside the role change, the article on automating WooCommerce review request emails covers that setup. For course access specifically, the guide on giving course access after a WooCommerce purchase goes deeper on the LearnDash side of the configuration.

    Cost Comparison: Plugin vs. Code vs. Workflow Automation

    Approach Year 1 cost Ongoing cost Execution logs Revocation support
    Code snippet only $0 Developer time to maintain Manual (error_log) Manual (second hook)
    Dedicated role plugin (e.g. Members Only) $69 to $149/year (estimated) Annual renewal Varies by plugin Yes, most include expiry
    Krom Automation free tier $0 $0 Full per-step audit trail Yes, via second workflow
    Krom Automation Pro (Basic plan) $69/year (launch price) $69/year or $199 lifetime Full per-step audit trail Yes, plus subscription triggers

    The free tier covers the core use case for most stores. Pro adds subscription-specific triggers, scheduled role expiry via the schedule trigger, and the visual email builder for the welcome message that follows the role change.

    Other Tools Worth Knowing About

    Pollify is wpRigel’s Gutenberg-native poll, survey and quiz plugin. Polls are built as real blocks inside the editor, so there are no shortcodes to paste and no separate admin panel to navigate. It pairs well with membership sites that want to survey members after they gain access.

    Commandify is a command palette for the WordPress admin. Press Cmd or Ctrl plus K to jump anywhere, search orders by customer name or email, and run admin actions without clicking through menus. It is the only command palette with real WooCommerce order, product and customer commands built in, which makes managing a high-volume store noticeably faster.

    Next Steps

    If you are starting fresh, install the free plugin, build the Order Completed workflow, test it with the simulator, and add the cancellation workflow immediately. Do not leave the revocation path for later. If you are already running a code snippet and it is mostly working, the most valuable addition is adding an execution log so you can see which orders triggered a role change and which ones silently failed.

    Try Krom Automation free on WordPress.org and build your first role-change workflow in under ten minutes. When you are ready to add subscription triggers, scheduled expiry, and the visual email builder, Pro plans start at $69 a year.

    Frequently Asked Questions

    Which WooCommerce hook should I use to trigger a role change after an order is completed?

    Use woocommerce_order_status_completed. It fires after the order status transitions to “completed”, which is the correct point because payment is confirmed and fulfilment is acknowledged. Do not use woocommerce_payment_complete, which fires at payment capture and may precede the completed status by hours on manual orders.

    What is the difference between set_role() and add_role() in WordPress?

    set_role() replaces the user’s existing primary role with the new one. add_role() adds the new role on top of any existing roles, resulting in a user with multiple roles.

    For most membership setups use set_role(). Use add_role() only if your access control layer explicitly supports and expects stacked roles.

    How do I change user role only when a specific product is purchased in WooCommerce?

    Loop through the order’s line items and check each item’s product ID against your target list using $item->get_product_id(). For variable products, also check wp_get_post_parent_id( $item->get_product_id() ) to match the parent product. Only call set_role() when a match is found.

    Can I change a user role after purchase if the customer checked out as a guest?

    Not directly, because guest orders have no associated WordPress user record. The cleanest solution is to require account creation at checkout in WooCommerce’s Accounts and Privacy settings. If you must support guest checkout, you can create a user account programmatically on order completion using wc_create_new_customer(), then assign the role to the new user ID.

    How do I revert a user role when a WooCommerce order is refunded or cancelled?

    Hook into woocommerce_order_status_refunded and woocommerce_order_status_cancelled. Inside the callback, confirm the order contains the qualifying product, then call $user->set_role( 'customer' ) to revert. Before reverting, query the user’s other completed orders to make sure you are not removing access they earned through a separate valid purchase.

    The wpRigel Team

    November 2, 2026
    Krom Automation, WooCommerce
1 2 3 … 23
Next Page
wprigel logo

wpRigel builds innovative WordPress plugins for developers, marketers and agencies. Be with us, get more users for your business and increase conversion using our powerful tools.

  • x.com icon
  • linkedin icon
  • wprigel youtube channel- youtube logo

Products

  • Pollify
  • Commandify
  • Krom Automation (Now Live 🎉)

Company

  • Affiliate Program
  • About Us
  • Contact Us
  • Privacy Policy

Resources

  • Docs
  • Blog
  • Support Area
  • Refund policy
  • Coupons & Deals

Comparisons

  • Commandify vs CommandUI
  • Pollify vs CrowdSignal
  • Krom Automation vs others

Changelogs

  • Commandify Changelog
  • Pollify Changelog
  • Krom Automation Pro Changelog

wpRigel 2026. All Rights Reserved

  • Terms of use
  • Privacy Policy
  • Cookie Policy