Skip to content

Instantly share code, notes, and snippets.

@mahfelwp
mahfelwp / bp_force_user_to_set_profile_avatar.php
Created June 23, 2019 09:50
Force user to choose pic for profile avatar in buddypress
<?php
function bp_force_user_to_set_profile_avatar() {
if ( ! is_user_logged_in() ) {
return;
}
$user_id = get_current_user_id();
if ( ! bp_get_user_has_avatar( $user_id ) && bp_current_action() != 'change-avatar' ) {
@mahfelwp
mahfelwp / add_new_column_to_plugin_table_in_new_version.php
Last active June 3, 2019 15:43
Add new column to plugin table in new version
<?php
final class Plugin_Name {
private function __construct() {
register_activation_hook( __FILE__, array( $this, 'plugin_activation' ) );
}
public function plugin_activation() {
if ( get_option( 'plugin_version' ) != PLUGIN_VERSION ) {
@mahfelwp
mahfelwp / remove_action_from_class.php
Created April 18, 2019 21:23
Access to Private Property of Class And Remove Action From Class
<?php
/**
* Access to Private Property of Class And Remove Action From Class
* add_action pirority is very important => 9
*/
function remove_action_from_class(){
global $Youzer;
$myClassReflection = new ReflectionClass( get_class( $Youzer ) );
$secret = $myClassReflection->getProperty('instance');
$secret->setAccessible(true);
@mahfelwp
mahfelwp / yz_include_members_directory_by_verified.php
Last active February 3, 2020 10:09
Include users only with "yz_account_verified" ##meta_key and "on" ##meta_value on members directory at Youzer plugin and also buddypress
<?php
/**
* Members Directory - Include Users By Meta_key & Meta_value
*/
function yz_include_members_directory_by_verified( $loop ) {
if ( ! bp_is_members_directory() ) {
return $loop;
}