Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Slava Abakumov slaFFik

🚀
View GitHub Profile
@slaFFik
slaFFik / wpforms-field-description-notification-emails.php
Last active Nov 23, 2020
WPForms: add field description in notification HTML and plain text emails
View wpforms-field-description-notification-emails.php
<?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 / wpforms-submit-form-once-loggedin.php
Last active Nov 22, 2020
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 / phpdox.xml
Created May 17, 2019
Full content of an example phpdox.xml file
View phpdox.xml
<?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 / wpms-smtp-disable-ssl-verify.php
Last active Sep 26, 2020
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-process-custom-smarttag.php
Last active Apr 14, 2020
WPForms: Process own smart tag (smarttag) with custom value
View wpforms-process-custom-smarttag.php
<?php
add_filter( 'wpforms_smart_tag_process', function ( $content, $tag ) {
// CHANGE custom_tag TO YOUR OWN SMART TAG NAME.
preg_match_all( '/custom_tag="(.+?)"/', $tag, $ids );
if ( ! empty( $ids[1] ) ) {
foreach ( $ids[1] as $key => $item_id ) {
// CHANGE HERE WHAT YOU WANT TO GET.
@slaFFik
slaFFik / wpforms-new-smarttag-current-time.php
Last active Apr 9, 2020
WPForms: new smart tag - current date and time
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;
} );
@slaFFik
slaFFik / bp-xprofile-countries-list.php
Last active Mar 16, 2020 — forked from shanebp/BuddyPress xprofile add countries
BuddyPress xProfile - Add Countries
View bp-xprofile-countries-list.php
<?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-new-smarttags-submitted-cpt.php
Last active Feb 14, 2020
WPForms: add several new smart tags for newly submitted CPT: ID, title and URL. Useful only for Post Submission addon.
View wpforms-new-smarttags-submitted-cpt.php
<?php
function wpf_dev_register_smarttag( $tags ) {
// Key is the tag, value is the tag name.
$tags['submitted_cpt_id'] = 'Submitted Post Type ID';
$tags['submitted_cpt_url'] = 'Submitted Post Type URL';
$tags['submitted_cpt_title'] = 'Submitted Post Type Title';
return $tags;
@slaFFik
slaFFik / wp-mail-smtp-authtype-login.php
Created Feb 5, 2020
WP Mail SMTP: specify an exact AuthType to connect to a Server.
View wp-mail-smtp-authtype-login.php
<?php
add_filter( 'wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->AuthType = 'LOGIN';
return $phpmailer;
} );
@slaFFik
slaFFik / bp-allow-not-admins-to-view-private-fields.php
Created Oct 6, 2016
BuddyPress: Allow not admins to see the private fields of other users
View bp-allow-not-admins-to-view-private-fields.php
<?php
function drs_bp_xprofile_reset_hidden_field_types_for_user( $hidden_levels, $displayed_user_id, $current_user_id ) {
if( $current_user_id == 9 ){ // or any other user role or user type check
return array();
}
return $hidden_levels;
}
add_filter( 'bp_xprofile_get_hidden_fields_for_user', 'drs_bp_xprofile_reset_hidden_field_types_for_user', 10, 3 );
You can’t perform that action at this time.