get('global_api_token'); $user_name = smart_sbv_core()->get('global_user_name'); // If API is not configured, remove the problematic action if (empty($api_token) || empty($user_name)) { forumax_remove_sbv_profile_action(); return; } // Test if API actually works $user = sbv_api()->user($user_name); if (is_wp_error($user)) { forumax_remove_sbv_profile_action(); } } /** * Remove the sbv_bbpress profile action that causes fatal errors */ function forumax_remove_sbv_profile_action() { global $sbv_bbpress; if (isset($sbv_bbpress) && is_object($sbv_bbpress)) { remove_action('bbp_template_after_user_profile', array($sbv_bbpress, 'bbp_template_after_user_profile')); } // Also try to find and remove by class name global $wp_filter; if (isset($wp_filter['bbp_template_after_user_profile'])) { foreach ($wp_filter['bbp_template_after_user_profile']->callbacks as $priority => $callbacks) { foreach ($callbacks as $key => $callback) { if (is_array($callback['function']) && is_object($callback['function'][0])) { if (get_class($callback['function'][0]) === 'sbv_bbpress') { unset($wp_filter['bbp_template_after_user_profile']->callbacks[$priority][$key]); } } } } } }