# bbp-core/2.5.0/includes/eazydocs-compatibility.php

Forumax – AI Powered Advanced Community Forum Plugin, version 2.5.0. 62 lines.

- Page: https://pluginprobe.com/plugins/bbp-core/2.5.0/code/includes/eazydocs-compatibility.php
- Raw: https://pluginprobe.com/plugins/bbp-core/2.5.0/raw/includes/eazydocs-compatibility.php
- Modified: 2026-10-06T10:18:02+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bbp-core/2.5.0/code/includes/eazydocs-compatibility.php#L10-L20`.

```php
<?php
/**
 * EazyDocs compatibility.
 *
 * EazyDocs' user_has_cap filter calls is_super_admin( $user->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;
}

```
