Skip to content

Instantly share code, notes, and snippets.

View slaFFik's full-sized avatar
🚀

Slava Abakumov slaFFik

🚀
View GitHub Profile
@slaFFik
slaFFik / wpforms-merge-field-values.php
Created January 23, 2020 14:06
WPForms: merge values for 2 fields into a 3rd one
<?php
add_filter( 'wpforms_entry_save_data', static function ( $fields, $entry, $form_data ) {
$value1 = '';
$value2 = '';
// These are field IDs to take data from, and to merge into.
$field1_id = 1;
$field2_id = 2;
@slaFFik
slaFFik / wpforms-change-country-code.php
Created June 3, 2019 18:26
WPForms: change the key of a country from country code to country name
<?php
add_filter( 'wpforms_countries', function ( $countries ) {
$key_from = 'CA';
if ( array_key_exists( $key_from, $countries ) ) {
$keys = array_keys( $countries );
$keys[ array_search( $key_from, $keys, true ) ] = 'Canada';
@slaFFik
slaFFik / phpdox.xml
Created May 17, 2019 11:58
Full content of an example phpdox.xml file
<?xml version="1.0" encoding="utf-8" ?>
<!-- This is a skeleton phpDox config file - Check http://phpDox.de for latest version and more info -->
<phpdox xmlns="http://xml.phpdox.net/config" silent="false">
<!-- @silent: true | false to enable or disable visual output of progress -->
<!-- Additional bootstrap files to load for additional parsers, enrichers and/or engines -->
<!-- Place as many require nodes as you feel like in this container -->
<!-- syntax: <require file="/path/to/file.php" /> -->
<bootstrap />
@slaFFik
slaFFik / wpforms-reformat-payment-fields-values-in-emails.php
Created October 8, 2018 17:59
WPForms: Make "$40.00 - Second Choice" instead of "Second Choice - $40.00" for different payment fields.
<?php
/**
* Make "$40.00 - Second Choice" instead of "Second Choice - $40.00"
* for different payment fields.
*/
add_filter( 'wpforms_html_field_value', function ( $value, $field, $form_data, $context ) {
if ( 'email-html' !== $context ) {
return $value;
}
@slaFFik
slaFFik / wpforms-custom-redirect.php
Last active September 17, 2021 22:16 — forked from jaredatch/functions.php
WPForms: Conditional form redirects based on field value.
<?php
/**
* WPForms: Conditional form redirects based on field value.
*
* @param string $url URL form will redirect to
* @param int $form_id Form ID
* @param array $fields Submitted form fields
* @return string
*/
function wpf_custom_redirect( $url, $form_id, $fields ) {
@slaFFik
slaFFik / wpms-smtp-disable-ssl-verify.php
Last active January 23, 2024 18:35
WP Mail SMTP: when using SMTP mailer - disable SSL verify on PHP 5.6+
<?php
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
@slaFFik
slaFFik / wp-mail-smtp-disable-smtpautotls.php
Created November 3, 2017 14:06
WP Mail SMTP: Disable SMTPAutoTLS
<?php
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->SMTPAutoTLS = false;
return $phpmailer;
} );
@slaFFik
slaFFik / wpforms-add-bcc-to-emails.php
Created October 16, 2017 15:49
WPForms: add BCC email header to notification emails
<?php
add_filter( 'wpforms_email_headers', function ( $headers, $emails ) {
// APPLY THE BCC TO THIS FORM ID ONLY.
// CHANGE THE ID TO THE FORM YOU NEED. OR REMOVE THE WHOLE IF BLOCK IF NEEDED FOR ALL FORMS.
if ( 384 !== $emails->form_data['id'] ) {
return $headers;
}
// CHANGE THIS EMAIL ADDRESS TO YOURS:
@slaFFik
slaFFik / wpforms-export-change-separator.php
Last active January 31, 2020 18:19
WPForms: change the export CSV file separator.
<?php
// For WPForms < v1.5.5, but should work with the latest version as well.
add_filter(
'wpforms_csv_export_separator',
function( $sep ) {
return ';';
}
);
<?php
add_filter( 'wpforms_currencies', function( $currencies ) {
$currencies['RON'] = array(
'name' => __( 'Romanian Leu', 'wpforms' ),
'symbol' => ' lei',
'symbol_pos' => 'right',
'thousands_separator' => ',',
'decimal_separator' => '.',
'decimals' => 2,