# automatorwp/6.0.3/integrations/advanced-ads/includes/triggers/ad-published.php

AutomatorWP – No-Code Workflow Automation, Integration &amp; Webhooks Plugin, now with AI, version 6.0.3. 81 lines.

- Page: https://pluginprobe.com/plugins/automatorwp/6.0.3/code/integrations/advanced-ads/includes/triggers/ad-published.php
- Raw: https://pluginprobe.com/plugins/automatorwp/6.0.3/raw/integrations/advanced-ads/includes/triggers/ad-published.php
- Modified: 2026-09-30T10:02:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/automatorwp/6.0.3/code/integrations/advanced-ads/includes/triggers/ad-published.php#L10-L20`.

```php
<?php
/**
 * Ad Published
 *
 * @package     AutomatorWP\Integrations\Advanced_Ads\Triggers\Ad_Published
 * @author      AutomatorWP <contact@automatorwp.com>, Ruben Garcia <rubengcdev@gmail.com>
 * @since       1.0.0
 */
// Exit if accessed directly
if( !defined( 'ABSPATH' ) ) exit;

class AutomatorWP_Advanced_Ads_Ad_Published extends AutomatorWP_Integration_Trigger {

    public $integration = 'advanced_ads';
    public $trigger = 'advanced_ads_ad_published';

    /**
     * Register the trigger
     *
     * @since 1.0.0
     */
    public function register() {

        automatorwp_register_trigger( $this->trigger, array(
            'integration'       => $this->integration,
            'label'             => __( 'User ad gets published', 'automatorwp' ),
            'select_option'     => __( 'User ad gets <strong>published</strong>', 'automatorwp' ),
            /* translators: %1$s: Number of times. */
            'edit_label'        => sprintf( __( 'User ad gets published %1$s time(s)', 'automatorwp' ), '{times}' ),
            'log_label'         => __( 'User ad gets published', 'automatorwp' ),
            'action'            => 'advanced-ads-ad-status-published',
            'function'          => array( $this, 'listener' ),
            'priority'          => 10,
            'accepted_args'     => 1,
            'options'           => array(
                'times' => automatorwp_utilities_times_option(),
            ),
            'tags' => array_merge(
                automatorwp_utilities_post_tags(),
                automatorwp_utilities_times_tag()
            )
        ) );

    }

    /**
     * Trigger listener
     *
     * @since 1.0.0
     *
     * @param Advanced_Ads_Ad $ad
     */
    public function listener( $ad ) {

        $ad_id = $ad->get_id( $ad );

        $post = get_post( $ad_id );

        // Bail if post does not exists
        if( ! $post ) {
            return;
        }

        $user_id = absint( $post->post_author );

        // Bail if post does not has an author assigned
        if( absint( $user_id === 0 ) ) {
            return;
        }

        automatorwp_trigger_event( array(
            'trigger'   => $this->trigger,
            'user_id'   => $user_id,
            'post_id'   => $ad_id,
        ) );

    }

}

new AutomatorWP_Advanced_Ads_Ad_Published();
```
