Skip to content

Instantly share code, notes, and snippets.

View slaFFik's full-sized avatar
🚀

Slava Abakumov slaFFik

🚀
View GitHub Profile
@slaFFik
slaFFik / wpforms-process-custom-smarttag.php
Last active April 14, 2020 07:08
WPForms: Process own smart tag (smarttag) with custom value
<?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-hide-forms-on-mobile.php
Created September 25, 2017 13:38
WPForms: Hide forms on mobile
<?php
add_filter( 'wpforms_frontend_load', function( $load, $form_data, $var ) {
// Comment these lines if you need to hide a certain form only.
if ( wp_is_mobile() ) {
return false;
}
// Or check certain form only. Uncomment.
/*
@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 / wpforms-split-name-smarttag-in-notifications.php
Last active August 29, 2017 09:01
WPForms: Split the first Name field to display only First Name in notification text
<?php
add_filter( 'wpforms_process_smart_tags', function ( $message, $form_data, $fields = '', $entry_id = 0 ) {
// CHANGE THIS FORM ID TO YOURS:
if ( 157 != $form_data['id'] ) {
return $message;
}
// So we are not submitting the form.
if ( empty( $entry_id ) ) {
return $message;
@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 / 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 / bp-allow-not-admins-to-view-private-fields.php
Created October 6, 2016 07:20
BuddyPress: Allow not admins to see the private fields of other users
<?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 );
@slaFFik
slaFFik / bp-prevent-duplicate-group-names.php
Last active February 3, 2020 11:23 — forked from shanebp/bp-prevent-duplicate-group-names.php
BuddyPress prevent duplicate Group Names
<?php
function pp_check_group_name( $group_new ) {
if ( 'group-details' == bp_get_groups_current_create_step() ) {
$args = array(
'per_page' => null,
'populate_extras' => false,
'update_meta_cache' => false
);
@slaFFik
slaFFik / blocklisted_emails.txt
Created March 24, 2016 08:15
List of domains (or their parts) that are blocked on my site
*@a3.mobile*
*@a3.accounting*
*@a3.news*
*@spambog.ru
*@get30daychange.com
*@qaqmail.com
*@mailcatch.com
*@discardmail.com
*@price*
*@baby.upheast*
@slaFFik
slaFFik / block-activity-types.php
Last active February 3, 2020 11:24 — forked from BoweFrankema/block-activity-types.php
BuddyPress Activity - don't save certain activity types
<?php
//Block certain activity types from being added
function bp_activity_dont_save( $activity_object ) {
$exclude = array(
'updated_profile',
'new_member',
'new_avatar',
'friendship_created',
'joined_group'
);