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-new-smarttags-submitted-cpt.php
Last active February 14, 2020 19:09
WPForms: add several new smart tags for newly submitted CPT: ID, title and URL. Useful only for Post Submission addon.
<?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 February 5, 2020 09:47
WP Mail SMTP: specify an exact AuthType to connect to a Server.
<?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 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 );
<?php
// Profile Edit Message
function cf_profile_field_intro_text() {
global $bp;
$user_id = bp_loggedin_user_id();
$profile_edit_link = bp_loggedin_user_domain() . $bp->profile->slug . 'profile/edit/group/2/';
if ( bp_get_profile_field_data( 'field=Your Relationship with CF&user_id='.$user_id) == FALSE && !bp_is_profile_edit() ) : ?>
<div id="complete-profile-message" class="intro-text important">
@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'
);
@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 / 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 / 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 ';';
}
);
@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';