id = 'slack'; $this->title = __( 'Slack', 'weforms' ); $this->icon = WEFORMS_ASSET_URI . '/images/icon-slack.svg'; $this->settings_fields = [ 'enabled' => false, 'url' => '', ]; add_action( 'weforms_entry_submission', [ $this, 'send_notification' ], 10, 4 ); } /** * Subscribe a user when a form is submitted * * @param int $entry_id * @param int $form_id * @param int $page_id * @param array $form_settings * * @return void */ public function send_notification( $entry_id, $form_id, $page_id, $form_settings ) { $integration = weforms_is_integration_active( $form_id, $this->id ); if ( false === $integration ) { return; } if ( empty( $integration->url ) ) { return; } $attachment_fields = []; $title = sprintf( __( '#%d New submission on %s', 'weforms' ), $entry_id, get_post_field( 'post_title', $form_id ) ); $form_data = weforms_get_entry_data( $entry_id ); if ( false === $form_data ) { return; } // prepare the attachment data foreach ( $form_data['fields'] as $meta_key => $value ) { $is_short = true; $_value = $form_data['data'][ $meta_key ]; if ( 'textarea' == $value['type'] ) { $is_short = false; $_value = html_entity_decode( $_value ); // replace paragrphs and breaks $_value = str_replace( '
', '', $_value );
$_value = str_replace( '
', '', $_value );
$_value = str_replace( '