Skip to content

Instantly share code, notes, and snippets.

@mahfelwp
Created April 18, 2019 21:23
Show Gist options
  • Save mahfelwp/995afa81f81247e19d6a0e8265b83230 to your computer and use it in GitHub Desktop.
Save mahfelwp/995afa81f81247e19d6a0e8265b83230 to your computer and use it in GitHub Desktop.
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);
remove_action( 'bp_init', array( $secret->getValue( $Youzer )->profile, 'init' ) );
}
add_action( 'bp_init', 'remove_action_from_class', 9 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment