ID ). On a single * site that calls $user->has_cap( 'delete_users' ), which re-enters the same * filter and recurses until PHP runs out of memory. * * Forumax topic pages trigger this because they resolve the topic author's * role and capabilities. The current viewer can be an administrator and still * fatal — the loop is on the author's user object, not the logged-in staff. * * @package Forumax */ defined( 'ABSPATH' ) || exit; /** * Replace the EazyDocs cap filter with a re-entry-safe wrapper. * * @return void */ function forumax_patch_eazydocs_user_has_cap() { if ( ! function_exists( 'ezd_filter_user_has_cap' ) ) { return; } remove_filter( 'user_has_cap', 'ezd_filter_user_has_cap', 10 ); add_filter( 'user_has_cap', 'forumax_safe_ezd_user_has_cap', 10, 4 ); } add_action( 'plugins_loaded', 'forumax_patch_eazydocs_user_has_cap', 99 ); /** * Run EazyDocs' cap grants without letting is_super_admin() recurse. * * @param array $allcaps All capabilities for the user. * @param array $caps Required capabilities being checked. * @param array $args Additional arguments passed to the check. * @param \WP_User $user The user object. * @return array */ function forumax_safe_ezd_user_has_cap( $allcaps, $caps, $args, $user ) { static $guard = array(); $uid = ( isset( $user->ID ) ) ? (int) $user->ID : 0; if ( $uid && isset( $guard[ $uid ] ) ) { return $allcaps; } if ( $uid ) { $guard[ $uid ] = true; } $allcaps = ezd_filter_user_has_cap( $allcaps, $caps, $args, $user ); if ( $uid ) { unset( $guard[ $uid ] ); } return $allcaps; }