• leanderbraunschweig

    (@leanderbraunschweig)


    Hi Felix,

    thanks for providing and maintaining this plugin, much appreciated!

    Upgrading to v1.0.20 I’ve noticed a fatal error upon deployment:

    Fatal error: Uncaught Error: Call to undefined function wp_get_current_user() in /srv/www/example.com/releases/20230627111755/web/wp/wp-includes/capabilities.php:873

    This is due to us including your plugin as an mu-plugin and wp_get_current_user() not being available yet…

    The code in question resides on line 758 in /admin/class-extended-post-status-admin.php and is attached to the gettext-filter.

    I am not sure if this can be re-written somehow to allow for the plugin to continue working as a mu-plugin…? Any ideas?

    Fixing the version to v1.0.19 for the time being.

    Thanks for your input & regards!

Viewing 1 replies (of 1 total)
  • Hey,
    The error message you’re seeing is because the wp_get_current_user() function is not defined at the time your plugin is trying to use it. This function is defined in the pluggable.php file, which is included by WordPress after all plugins are loaded. If a plugin is loaded before pluggable.php is included, it can’t use any of the functions defined in that file.

    I think the plugin developer forgot about this. But you can fix this by checking if the function wp_get_current_user() exists before calling current_user_can().

    In line 758, change it to this:
    if ($original == 'Post published.' && function_exists('wp_get_current_user') && current_user_can('publish_posts')) {

Viewing 1 replies (of 1 total)
  • The topic ‘Fatal error with v1.0.20 when using as mu-plugin’ is closed to new replies.