??????????????
??????????????
??????????????
??????????????
Warning : Undefined variable $auth in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
Warning : Trying to access array offset on value of type null in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
??????????????
??????????????
??????????????
??????????????
File Manager
✏️ Edit File: /home/mklsvubc/renovaid.co.uk/wp-content/plugins/latepoint/lib/abilities/agents/create-agent.php
⬅ Kembali
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class LatePointAbilityCreateAgent extends LatePointAbstractAgentAbility {
protected function configure(): void {
$this->id = 'latepoint/create-agent';
$this->label = __( 'Create agent', 'latepoint' );
$this->description = __( 'Creates a new agent (staff member) who can be assigned to services and receive bookings.', 'latepoint' );
$this->permission = 'agent__create';
$this->read_only = false;
$this->destructive = false;
$this->idempotent = false;
}
public function get_input_schema(): array {
return [
'type' => 'object',
'properties' => [
'first_name' => [
'type' => 'string',
'description' => __( 'First name.', 'latepoint' ),
],
'last_name' => [ 'type' => 'string' ],
'email' => [
'type' => 'string',
'format' => 'email',
],
'phone' => [ 'type' => 'string' ],
'bio' => [ 'type' => 'string' ],
'wp_user_id' => [
'type' => 'integer',
'description' => __( 'Link to WordPress user.', 'latepoint' ),
],
],
'required' => [ 'first_name', 'email' ],
];
}
public function get_output_schema(): array {
return $this->agent_output_schema();
}
public function execute( array $args ) {
$agent = new OsAgentModel();
$agent->first_name = sanitize_text_field( $args['first_name'] );
$agent->email = sanitize_email( $args['email'] );
$agent->status = LATEPOINT_AGENT_STATUS_ACTIVE;
if ( ! empty( $args['last_name'] ) ) {
$agent->last_name = sanitize_text_field( $args['last_name'] );
}
if ( ! empty( $args['phone'] ) ) {
$agent->phone = sanitize_text_field( $args['phone'] );
}
if ( ! empty( $args['bio'] ) ) {
$agent->bio = sanitize_textarea_field( $args['bio'] );
}
if ( ! empty( $args['wp_user_id'] ) ) {
$agent->wp_user_id = (int) $args['wp_user_id'];
}
if ( ! $agent->save() ) {
return new WP_Error(
'save_failed',
__( 'Failed to create agent.', 'latepoint' ),
WP_DEBUG ? [ 'errors' => $agent->get_error_messages() ] : [ 'status' => 422 ]
);
}
return $this->serialize_agent( new OsAgentModel( $agent->id ) );
}
}
Nama
Tipe
Ukuran
Diubah
Aksi
🐘 abstract-agent-ability.php
php
1.4 KB
2026-03-10 11:15
🐘 create-agent.php
php
2.2 KB
2026-03-10 11:15
🐘 delete-agent.php
php
1.4 KB
2026-03-10 11:15
🐘 disable-agent.php
php
1.4 KB
2026-03-10 11:15
🐘 enable-agent.php
php
1.3 KB
2026-03-10 11:15
🐘 get-agent-bookings.php
php
2.6 KB
2026-03-10 11:15
🐘 get-agent-revenue.php
php
1.9 KB
2026-03-10 11:15
🐘 get-agent-services.php
php
2.2 KB
2026-03-10 11:15
🐘 get-agent.php
php
1 KB
2026-03-10 11:15
🐘 get-agents.php
php
1.4 KB
2026-03-10 11:15
🐘 update-agent.php
php
2.1 KB
2026-03-10 11:15