Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Slava Abakumov slaFFik

🚀
View GitHub Profile
@slaFFik
slaFFik / wpforms-display-form-under-confirmation.php
Created February 22, 2021 15:24
WPForms: display a form under the confirmation message with or without user entered field values.
View wpforms-display-form-under-confirmation.php
<?php
add_action(
'wpforms_frontend_output_success',
static function ( $form_data, $fields, $entry_id ) {
unset(
$_GET['wpforms_return'],
$_POST['wpforms']['id']
);
@slaFFik
slaFFik / wpforms-merge-field-values.php
Created January 23, 2020 14:06
WPForms: merge values for 2 fields into a 3rd one
View wpforms-merge-field-values.php
<?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 / wpms-smtp-disable-ssl-verify.php
Last active March 10, 2023 08:31
WP Mail SMTP: when using SMTP mailer - disable SSL verify on PHP 5.6+
View wpms-smtp-disable-ssl-verify.php
<?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 / wpforms-new-smarttag-current-time.php
Last active February 3, 2023 15:01
WPForms: new smart tag - current date and time, also Unix timestamp
View wpforms-new-smarttag-current-time.php
<?php
// Register the smart tag.
add_filter( 'wpforms_smart_tags', static function( $tags ) {
// Key is the tag, value is the tag name.
$tags['current_time'] = 'Current Date/Time';
return $tags;
} );
View wpforms-add-new-currency.php
<?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,
@slaFFik
slaFFik / expose.php
Created January 31, 2021 19:27
Fix Expose by BeyondCode issues when working with the local WordPress site
View expose.php
<?php
// phpcs:ignoreFile
define( 'EXPOSED_DOMAIN', 'example.sharedwithexpose.com' );
// Load only if we are running under Expose.
if ( empty( $_SERVER['HTTP_X_ORIGINAL_HOST'] ) || $_SERVER['HTTP_X_ORIGINAL_HOST'] !== EXPOSED_DOMAIN ) {
return;
}
@slaFFik
slaFFik / wpforms-submit-form-once-loggedin.php
Last active August 31, 2022 11:32
WPForms: Submit the form only once for logged in users.
View wpforms-submit-form-once-loggedin.php
<?php
add_action( 'wp', function () {
if ( ! is_user_logged_in() ) {
return;
}
$entries = wpforms()->entry->get_entries(
array(
'form_id' => 74, // CHANGE THIS FORM ID
@slaFFik
slaFFik / wpforms-add-bcc-to-emails.php
Created October 16, 2017 15:49
WPForms: add BCC email header to notification emails
View wpforms-add-bcc-to-emails.php
<?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 / console.save.js
Created December 24, 2021 22:48
Save data from DevTools console to a JSON file with console.save()
View console.save.js
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data');
return;
}
if(!filename) filename = 'console.json';
@slaFFik
slaFFik / wp-mail-smtp-disable-smtpautotls.php
Created November 3, 2017 14:06
WP Mail SMTP: Disable SMTPAutoTLS
View wp-mail-smtp-disable-smtpautotls.php
<?php
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->SMTPAutoTLS = false;
return $phpmailer;
} );