[ SYSTEM ]: Linux wordpress 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
[ SERVER ]: Apache/2.4.66 (Debian) | PHP: 8.2.30
[ USER ]: www-data | IP: 172.19.30.54
GEFORCE FILE MANAGER
/
var
/
www
/
html
/
wordpress
/
wp-content
/
plugins
/
suretriggers
/
src
/
Integrations
/
fluent-support
/
actions
/
UPLOAD:
NAME
SIZE
QUICK PERMS
ACTIONS
📄 add-tag-to-ticket.php
3,295 B
SET
[ EDIT ]
|
[ DEL ]
📄 create-or-obtain-customer.php
2,706 B
SET
[ EDIT ]
|
[ DEL ]
DELETE SELECTED
[ CLOSE ]
EDIT: create-or-obtain-customer.php
<?php /** * CreateOrObtainCustomer. * php version 5.6 * * @category CreateOrObtainCustomer * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\FluentSupport\Actions; use Exception; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use FluentSupport\App\Models\Customer; /** * CreateOrObtainCustomer * * @category CreateOrObtainCustomer * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class CreateOrObtainCustomer extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'FluentSupport'; /** * Action name. * * @var string */ public $action = 'create_or_obtain_customer_fluent_support'; use SingletonLoader; /** * Register a action. * * @param array $actions actions. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Create Or Obtain Customer', 'suretriggers' ), 'action' => $this->action, 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selected_options. * * @return array|void * * @throws Exception Exception. */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $email = sanitize_email( $selected_options['customer_email'] ); $first_name = sanitize_text_field( $selected_options['first_name'] ); $last_name = sanitize_text_field( $selected_options['last_name'] ); if ( ! is_email( $email ) ) { return [ 'status' => 'error', 'message' => 'Invalid email.', ]; } if ( ! class_exists( 'FluentSupport\App\Models\Customer' ) ) { return [ 'status' => 'error', 'message' => 'Error: Plugin did not installed correctly. Some classes are missing.', ]; } $customer_record = Customer::where( 'email', $email )->first(); if ( ! $customer_record ) { $customer = [ 'email' => $email, 'first_name' => $first_name, 'last_name' => $last_name, ]; Customer::create( $customer ); $customer_record = Customer::where( 'email', $email )->first(); } return $customer_record->getAttributes(); } } CreateOrObtainCustomer::get_instance();