Skip to content

Instantly share code, notes, and snippets.

View slaFFik's full-sized avatar
🚀

Slava Abakumov slaFFik

🚀
View GitHub Profile
@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.
<?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 / console.save.js
Created December 24, 2021 22:48
Save data from DevTools console to a JSON file with console.save()
(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
<?php
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->SMTPAutoTLS = false;
return $phpmailer;
} );
@slaFFik
slaFFik / ab-bp-retroactiveusers.php
Last active November 16, 2021 22:52 — forked from technosailor/ab-bp-retroactiveusers.php
Populate WordPress User Meta so that even users who have never logged in will display on the Members BP page
<?php
/*
Plugin Name: Retroactive BP User Acticity
Plugin URI: https://gist.github.com/3953927
Description: Makes all BuddyPress users visible immediately on user creation and retroactively adjust users to allow for their display before logging in.
Author: Aaron Brazell
Version: 1.0
Author URI: http://technosailor.com
License: MIT
License URI: http://opensource.org/licenses/MIT
@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 / bp-xprofile-countries-list.php
Last active April 1, 2021 14:57 — forked from shanebp/BuddyPress xprofile add countries
BuddyPress xProfile - Add Countries
<?php
/**
* If you are using BP 2.1+, this will insert a Country selectbox.
* Add the function to bp-custom.php and then visit .../wp-admin/users.php?page=bp-profile-setup
*/
function bp_add_custom_country_list() {
if ( !xprofile_get_field_id_from_name('Country') && 'bp-profile-setup' == $_GET['page'] ) {
@slaFFik
slaFFik / wpforms-remove-single-entry-page-sections.php
Last active February 10, 2021 19:24
WPForms: hide certain sections on a single entry page: notes, log, debug, meta, payment, actions, related, geolocation.
<?php
/**
* This code removes all sections on a single entry page in the admin area.
* Methods names in the remove_action() function call are self explanatory.
* Comment out or remove those lines which sections you want to show.
*/
// Main content area.
add_action( 'wpforms_entry_details_content', static function ( $entry, $form_data, $single_entry ) {
@slaFFik
slaFFik / wpforms-change-js-validation-form-id.php
Last active January 1, 2021 13:04
WPForms: Change the JS validation strings based on a form ID (useful for multi-language sites)
<?php
add_filter( 'wpforms_frontend_strings', function( $strings ) {
global $post;
if ( ! isset( $post->post_content ) ) {
return $strings;
}
preg_match( '~\[wpforms id=\"(\d+)\"~', $post->post_content, $matches );
@slaFFik
slaFFik / wpforms-field-description-notification-emails.php
Last active November 23, 2020 20:31
WPForms: add field description in notification HTML and plain text emails
<?php
// HTML Email.
add_filter( 'wpforms_html_field_value', static function ( $field_val, $field, $form_data, $context ) {
if ( $context !== 'email-html' ) {
return $field_val;
}
if ( empty( $form_data['fields'][ $field['id'] ] ) ) {
@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 />