Encountered a very frustrating bug after many hours of debugging through xDebug. A function that was added to a hook through add_action is missing or inaccessible when do_action is fired from within a plugin(BuddyPress).
The function I am referring to in my theme folder: UpdateSalesForceAvatar
Action: 'bp_members_avatar_uploaded'
Theme code where add_action for the above function is added:
public static function RegisterActions(): void {
add_action( 'xprofile_data_after_save', [self::class, 'UpdateSalesforce'] );
add_action( 'xprofile_data_after_delete', [self::class, 'UpdateSalesforce'] );
add_action( 'bp_members_avatar_uploaded', [self::class, 'UpdateSalesForceAvatar'], 10, 3);
add_filter( 'bp_core_avatar_folder_dir', [self::class, 'HandleAvatarFolderDir']);
}
Function prototype for UpdateSalesForceAvatar:
public static function UpdateSalesForceAvatar($item_id, $type, $avatar_data) {
Here are the screenshots and debug information that will hopefully allow someone to help me understand why it is missing when the global $wp_filters is accessed from the plugin.
1st screenshot after add_action
2nd screenshot after future execution of code within BuddyPress
Any and all feedback is appreciated!
Sometimes you have to try another location, potentially because of plugins interacting with that action.
The solution was more of a workaround, moved the registration of the action instead to functions.php