Noptin_Automation_Rules::admin_create_automation_rule()

Saves a created rule


Return Return

(void)


Top ↑

Source Source

File: includes/automation-rules/class-noptin-automation-rules.php

	public function admin_create_automation_rule() {

        if ( ! current_user_can( get_noptin_capability() ) || empty( $_POST['noptin-admin-create-automation-rule'] ) ) {
			return;
		}

		if ( ! wp_verify_nonce( $_POST['noptin-admin-create-automation-rule'], 'noptin-admin-create-automation-rule' ) ) {
			return;
        }

        $post       = wp_unslash( $_POST );
        $action_id  = noptin_clean( $post[ 'action' ] );
        $trigger_id = noptin_clean( $post[ 'trigger' ] );
        $rule       = $this->create_rule( compact( 'action_id', 'trigger_id' ) );

        if ( ! empty( $rule ) ) {
            wp_redirect(
                add_query_arg(
                    'edit',
                    $rule->id,
                    admin_url( 'admin.php?page=noptin-automation-rules' )
                )
            );
            exit;
        }

        noptin()->admin->show_error( __( 'There was a problem creating your automation rule. Please try again.', 'newsletter-optin-box' ) );

    }


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.3.0Introduced.

Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation