Skip to content

Hook e Filter PHP (Action e Filter) ​

QoraCRM fornisce ricchi punti di estensione per WordPress tramite gli standard add_action e add_filter. Puoi utilizzare questi hook nei tuoi plugin personalizzati o nel file functions.php del tuo tema child.


Action ​

qoracrm_lead_created ​

Viene eseguito subito dopo il salvataggio riuscito di un nuovo lead nel database. Viene attivato su tutti i canali di creazione dei lead: moduli nativi QoraCRM, integrazioni di moduli di terze parti (CF7, WPForms, Elementor, ecc.), creazione manuale tramite admin CRM e webhook API.

php
/**
 * @param int   $lead_id    The database ID of the created lead.
 * @param int   $form_id    The form ID (or 0 for manual/webhook leads).
 * @param array $entry_data Associative array of submitted field data.
 */
add_action( 'qoracrm_lead_created', function( $lead_id, $form_id, $entry_data ) {
    // Example: send lead data to custom third-party ERP/CRM
    error_log( "New lead #{$lead_id} created for form #{$form_id}!" );
}, 10, 3 );

qoracrm_lead_deleted ​

Viene eseguito dopo l'eliminazione di un lead dal CRM.

php
/**
 * @param int $lead_id The ID of the deleted lead.
 */
add_action( 'qoracrm_lead_deleted', function( $lead_id ) {
    // Custom cleanup logic
}, 10, 1 );

qoracrm_leads_batch_deleted ​

Viene eseguito quando più lead vengono eliminati simultaneamente tramite azione di massa.

php
/**
 * @param int[] $lead_ids Array of deleted lead IDs.
 */
add_action( 'qoracrm_leads_batch_deleted', function( $lead_ids ) {
    // Batch cleanup logic
}, 10, 1 );

qoracrm_save_settings ​

Viene eseguito ogni volta che le impostazioni del plugin vengono aggiornate tramite REST API.

php
/**
 * @param array $params           Submitted settings data.
 * @param array $current_settings Existing settings before update.
 */
add_action( 'qoracrm_save_settings', function( $params, $current_settings ) {
    // Custom post-settings save logic
}, 10, 2 );

Filter ​

qoracrm_form_render_fields ​

Consente di modificare, riordinare, aggiungere o rimuovere dinamicamente i campi del modulo prima che l'HTML del modulo venga renderizzato nella pagina.

php
/**
 * @param array $fields  List of field definitions in the form.
 * @param int   $form_id The form ID being rendered.
 * @return array
 */
add_filter( 'qoracrm_form_render_fields', function( $fields, $form_id ) {
    // Dynamically inject or modify fields
    return $fields;
}, 10, 2 );

qoracrm_leads_response ​

Filtra l'array dei lead recuperati dal database prima di restituire la risposta REST API.

php
/**
 * @param array $leads Array of lead objects.
 * @return array
 */
add_filter( 'qoracrm_leads_response', function( $leads ) {
    // Format or mask sensitive lead fields
    return $leads;
} );

qoracrm_lead_response ​

Filtra un singolo oggetto lead prima della restituzione tramite REST API.

php
/**
 * @param array $lead Single lead data array.
 * @return array
 */
add_filter( 'qoracrm_lead_response', function( $lead ) {
    return $lead;
} );

qoracrm_user_has_crm_access ​

Consente di concedere l'accesso al CRM a utenti specifici, ruoli utente o capacità oltre agli amministratori standard (manage_options).

php
/**
 * @param bool $has_access Default access flag.
 * @param int  $user_id    Current WordPress user ID.
 * @return bool
 */
add_filter( 'qoracrm_user_has_crm_access', function( $has_access, $user_id ) {
    $user = get_userdata( $user_id );
    if ( $user && in_array( 'sales_manager', (array) $user->roles, true ) ) {
        return true;
    }
    return $has_access;
}, 10, 2 );

qoracrm_allowed_statuses ​

Filtra l'elenco degli stati validi dei lead accettati durante l'invio e gli aggiornamenti dei lead.

php
/**
 * @param string[] $allowed_statuses Array of status slugs.
 * @return string[]
 */
add_filter( 'qoracrm_allowed_statuses', function( $allowed_statuses ) {
    $allowed_statuses[] = 'in_review';
    return $allowed_statuses;
} );

Released under GPL-2.0+ License.