Plugin Author
bnfw
(@voltronik)
Hi @intuitart,
Thanks for your message.
I think this might happen if you have the Members plugin enabled but aren’t allowing a user to have multiple user roles.
Are you able to verify this setting and see if it helps when enabled?
Yes, ‘Allow users to be assigned more than a single role.’ is checked. I am assigning multiple roles.
Further to my original message, when I hack line 1184 in the code and make $hook_name a string, everything works fine.
From WordPress developer resources, the apply_filters function is a string, not a string or array:
apply_filters( string $hook_name, mixed $value )
Your code is defining it as a array:
return apply_filters( array( $this, 'bnfw_members_sanitize_role' ), str_replace( ' ', '_', $_role ), $role );
To make things work I changed that to:
return apply_filters( 'bnfw_members_sanitize_role', str_replace( ' ', '_', $_role ), $role );
Hope this helps,
Andrew P.
Plugin Author
bnfw
(@voltronik)
Thanks @intuitart,
I’ll do some testing and provide a fix in the next update to the plugin.
Ash
(@smartfaceweb)
I can confirm I am experiencing the same issue and can see that you are passing an array into the apply_filters() method when the doc block shows that it expects a string.
/wp-includes/plugin.php
* @since 0.71
*
* @global WP_Hook[] $wp_filter Stores all of the filters and actions.
* @global string[] $wp_current_filter Stores the list of current filters with the current one last.
*
* @param string $hook_name The name of the filter hook.
* @param mixed $value The value to filter.
* @param mixed ...$args Additional parameters to pass to the callback functions.
* @return mixed The filtered value after all hooked functions are applied to it.
*/
function apply_filters( $hook_name, $value ) {
Plugin Author
bnfw
(@voltronik)
Thanks for your confirmation @smartfaceweb.
Ash
(@smartfaceweb)
Any ETA on when the update will be ready? Currently to change a user’s role, I need to disable this plugin, change the role and then re-enable the plugin.
Plugin Author
bnfw
(@voltronik)
Hi @smartfaceweb,
No ETA as yet but you’re welcome to modify the bnfw plugin to include the fix mentioned above in order to circumvent the issue until a release is made.
Hello,
I sorry,
but I do not have the same code on BNFW 1.8.11 and I still have the same trouble “fatal error”
How can fix it?
function apply_filters( $hook_name, $value ) {
global $wp_filter, $wp_current_filter;
$args = func_get_args();
// Do 'all' actions first.
if ( isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $hook_name;
_wp_call_all_hook( $args );
}
if ( ! isset( $wp_filter[ $hook_name ] ) ) {
if ( isset( $wp_filter['all'] ) ) {
array_pop( $wp_current_filter );
}
return $value;
}
if ( ! isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $hook_name;
}
// Don't pass the tag name to WP_Hook.
array_shift( $args );
$filtered = $wp_filter[ $hook_name ]->apply_filters( $value, $args );
array_pop( $wp_current_filter );
return $filtered;
}
Plugin Author
bnfw
(@voltronik)
Hi @sebastiengiran,
The fix can be found in this post:
https://wordpress.org/support/topic/fatal-error-when-used-with-members-plugin-2/#post-15580156
You need to replace the code on line 1184 of bnfw.php that reads:
return apply_filters( array( $this, 'bnfw_members_sanitize_role' ), str_replace( ' ', '_', $_role ), $role );
with this:
return apply_filters( 'bnfw_members_sanitize_role', str_replace( ' ', '_', $_role ), $role );
Let me know if this helps.
Where do I find the bnfw.php on the server?
Ok, I finded it, it’s works, thank you so much
Best regards
Plugin Author
bnfw
(@voltronik)
Hi @sebastiengiran,
Great! Glad you got it working. An update with this fix will be released soon.
Hi @voltronik,
I ran into this issue today on Version 1.8.11 + custom fields & conditional notifications add-ons. The fix above worked for me (thanks @intuitart!).
Should I tell my client to not update BNFW, or will this fix for sure be in the next version?
Thanks!
Plugin Author
bnfw
(@voltronik)
Hi @invouq,
Yes, the fix is already ready in my development version and will be included in the next version of BNFW.