• Resolved Puggy

    (@puggy)


    I ran into a bug tonight with this plugin while using another plugin, New Blog Templates by WPMU Dev. Their plugin has an option to block editing of posts/pages created with a template which causes the user_has_cap filter used by this plugin to pass a boolean (presumably false) instead of an array as the first parameter of the filter. Since the parameters are strongly typed in this plugin, it throws a fatal error.

    I’d say this is more of a bug in core or at least in the ‘user_has_cap’ filter documentation, since it says that the it’s always supposed to pass an array. Either way, I managed to fix the issue by removing the array type-casting for $user_caps on line 497 in this plugin and doing a test to ensure it’s an array before attempting to modify it – if it’s not an array, I’m just returning it and it seems to work fine.

    https://www.ads-software.com/plugins/user-switching/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    The core documentation is correct – the first parameter to the user_has_cap filter must be an array of user capabilities. Boolean false makes no sense for this parameter.

    Therefore this is indeed a bug in the New Blog Templates plugin. It should use the map_meta_cap filter instead, and add do_not_allow to the returned array. Basically the same as the filter_map_meta_cap() method in User Switching does.

    Thread Starter Puggy

    (@puggy)

    I see your point. I’ll let them know about this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘fatal error on filter_user_has_cap() call’ is closed to new replies.