Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Slava Abakumov slaFFik

🚀
View GitHub Profile
@slaFFik
slaFFik / gist:3491627
Last active Oct 9, 2015
Redirect users from a home page to any page if logged in [WordPress]
View gist:3491627
<?php
add_action( 'template_redirect', 'redirect_visitors' );
function redirect_visitors() {
if( is_user_logged_in() && (is_front_page() || is_home())) {
wp_redirect('http://ab.ovi/test2');
exit;
}
}
?>
@slaFFik
slaFFik / pvar.php
Last active Dec 7, 2017
Nicely display the var content
View pvar.php
<?php
/**
* Nicely display the var content.
*
* @param mixed $var
* @param bool $die
*/
function pvar( $var = '', $die = false ) {
echo '<pre>' . PHP_EOL;
@slaFFik
slaFFik / fix_bp_nextgen.php
Created Jun 13, 2014
Fix for BuddyPress and NextGen Gallery
View fix_bp_nextgen.php
<?php
function ovi_kill_anonymous_hooks(){
ovi_remove_anonymous_object_filter(
'wp_footer',
'C_Photocrati_Resource_Manager',
'print_marker'
);
}
add_action('wp_footer', 'ovi_kill_anonymous_hooks', -2);
@slaFFik
slaFFik / dndrpawwd.php
Last active Aug 29, 2015
Do not display Recent Posts in Activity widget in WordPress Dashboard
View dndrpawwd.php
<?php
if ( strpos($_SERVER['SCRIPT_FILENAME'], 'wp-admin/index.php') && !defined('DOING_AJAX')) {
add_filter('the_posts', 'dndrpawwd', 10, 2);
}
function dndrpawwd($posts, $obj){
$trace = debug_backtrace();
foreach($trace as $item) {
if ($item['function'] == 'wp_dashboard_recent_posts' ) {
@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'] ) {
View xprofile-field-message.php
<?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 Feb 3, 2020 — forked from BoweFrankema/block-activity-types.php
BuddyPress Activity - don't save certain activity types
View block-activity-types.php
<?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 Mar 24, 2016
List of domains (or their parts) that are blocked on my site
View blocklisted_emails.txt
*@a3.mobile*
*@a3.accounting*
*@a3.news*
*@spambog.ru
*@get30daychange.com
*@qaqmail.com
*@mailcatch.com
*@discardmail.com
*@price*
*@baby.upheast*
View bp-prevent-duplicate-group-names.php
<?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 / 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.