• Resolved Daniel Avram

    (@danieldumitruavram)


    Hi there,

    I’m encountering a fatal error when activating Rank Math on one of my websites:

    Uncaught Error: Call to undefined function RankMath\Admin\wp_get_current_user()  
    in /wp-content/plugins/seo-by-rank-math/includes/admin/class-admin-menu.php:53

    It seems the function wp_get_current_user() is being called too early in the WordPress load sequence — before pluggable.php is loaded, where this function is defined.

    A temporary fix is to wrap the call like this:

    if ( ! function_exists( 'wp_get_current_user' ) ) {  
    require_once ABSPATH . 'wp-includes/pluggable.php';
    }

    However, the best long-term solution would be to ensure this call runs only after WordPress has fully loaded the pluggable functions — ideally using the plugins_loaded or init hook.

    Please consider addressing this in a future update to prevent similar issues. Let me know if you need more details or access to the environment.

    Thanks for your support and for the great plugin!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @danieldumitruavram,
     
    Thank you so much for reaching out.
     
    Rank Math calls wp_get_current_user() inside the init hook (line 37), which runs after WordPress loads pluggable functions — so this error shouldn’t normally occur.
     
    It’s possible that another plugin or custom code is triggering things early. Could you please share the list of active plugins or any custom setup on the site? That will help us investigate further.
     
    Meanwhile, you can check first if the issue goes away when all plugins except Rank Math are disabled and the default theme is active. You may follow this troubleshooting guide so your users will not be affected: https://rankmath.com/kb/check-plugin-conflicts/
     
    Looking forward to your reply.

    Thread Starter Daniel Avram

    (@danieldumitruavram)

    I’m encountering the same fatal error again that I reported previously. The error message is:

    Uncaught Error: Call to undefined function RankMath\Admin\wp_get_current_user() in /wp-content/plugins/seo-by-rank-math/includes/admin/class-admin-menu.php:53

    After this happens, the site goes completely down, and the only way to temporarily fix it is by changing the PHP version from cPanel, which resets things and brings the site back online.

    Here’s what I’ve confirmed on my end:

    • I’m using the latest version of WordPress and Rank Math.
    • I’ve added the correct debug configuration in wp-config.php, but the fatal error doesn’t get logged in wp-content/debug.log — probably because it occurs too early in the execution.
    • Based on your previous answer, I understand this function is only called inside the init hook, which should be safe. However, the issue still happens, indicating something (perhaps a plugin or custom code) is triggering execution too early and causing Rank Math to load before pluggable.php is available.

    I’d really appreciate it if you could:

    1. Confirm if there’s any known fix or update for this issue.
    2. Suggest a way to prevent Rank Math from loading until wp_get_current_user() is guaranteed to be available, or at least gracefully fail instead of throwing a fatal error.

    Thanks in advance

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @danieldumitruavram,
     
    Please navigate to WP Dashboard > Rank Math SEO > System Status > Copy System Info to Clipboard and share it with us so we can investigate this further.
     
    Looking forward to helping you.

    Thread Starter Daniel Avram

    (@danieldumitruavram)

    ` rank-math

    version: 1.0.249
    database_version: 1
    plugin_plan: Free
    active_modules: sitemap, rich-snippet, woocommerce, redirections, link-counter, instant-indexing, 404-monitor, analytics
    refresh_token: Tokenul există
    permissions:
    Consolă de căutare: Ai acordat
    rank_math_404_logs: 32 Ko
    rank_math_redirections: 32 Ko
    rank_math_redirections_cache: 112 Ko
    rank_math_internal_links: 2 Mo
    rank_math_internal_meta: 128 Ko
    rank_math_analytics_gsc: 896 Ko
    rank_math_analytics_objects: 240 Ko
    rank_math_analytics_inspections: 480 Ko wp-core

    version: 6.8.2
    site_language: ro_RO
    user_language: ro_RO
    timezone: Europe/Bucharest
    permalink: /%postname%/
    https_status: true
    multisite: false
    user_registration: 1
    blog_public: 1
    default_comment_status: open
    environment_type: production
    user_count: 10
    dotorg_communication: true wp-dropins (2)

    advanced-cache.php: true
    maintenance.php: true wp-active-theme

    name: Ecomus (ecomus)
    version: 2.1.1
    author: Drfuri
    author_website: http://drfuri.com
    parent_theme: none
    theme_features: core-block-patterns, widgets-block-editor, post-thumbnails, automatic-feed-links, title-tag, html5, customize-selective-refresh-widgets, editor-style, editor-styles, wp-block-styles, responsive-embeds, align-wide, align-full, menus, woocommerce, wc-product-gallery-slider, wc-product-gallery-lightbox, widgets
    theme_path: /home/sexshopr/public_html/wp-content/themes/ecomus
    auto_update: Dezactivată wp-plugins-active (23)

    Code Snippets: version: 3.6.8, author: Code Snippets Pro, Actualizările automate sunt dezactivate
    Contact Form 7: version: 6.6.4, author: Takayuki Miyoshi, Actualizările automate sunt dezactivate
    Ecomus Addons: version: 2.1.0, author: Drfuri, Actualizările automate sunt dezactivate
    Elementor: version: 3.30.2, author: Elementor.com, Actualizările automate sunt dezactivate
    Facturare - Persoana Fizica sau Juridica: version: 1.2.6, author: Avian Studio, Actualizările automate sunt dezactivate
    FluentSMTP: version: 2.2.90, author: FluentSMTP & WPManageNinja Team, Actualizările automate sunt dezactivate
    FunnelKit Payment Gateway for Stripe WooCommerce: version: 1.12.2, author: FunnelKit, Actualizările automate sunt dezactivate
    Imagify: version: 2.2.6, author: Imagify Image Optimizer – Optimize Images & Convert WebP & Avif, Actualizările automate sunt dezactivate
    IndiaSan Customization: version: 1.0.0, author: IndiaSan, Actualizările automate sunt dezactivate
    Loco Translate: version: 2.8.0, author: Tim Whitlock, Actualizările automate sunt dezactivate
    Perfmatters: version: 2.4.7, author: forgemedia, Actualizările automate sunt dezactivate
    Rank Math SEO: version: 1.0.249, author: Rank Math SEO, Actualizările automate sunt dezactivate
    Really Simple Security: version: 9.4.2, author: Really Simple Security, Actualizările automate sunt dezactivate
    SamedayCourier Shipping: version: 1.10.6, author: SamedayCourier, Actualizările automate sunt dezactivate
    Stock Sync for WooCommerce Pro: version: 2.8.1, author: Lauri Karisola / WP Trio (latest version: 2.9.0), Actualizările automate sunt dezactivate
    TranslatePress - Multilingual: version: 2.9.20, author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban, Actualizările automate sunt dezactivate
    Two Factor: version: 0.14.0, author: ww.wp.xz.cn Contributors, Actualizările automate sunt dezactivate
    WCBoost - Variation Swatches: version: 1.1.2, author: WCBoost, Actualizările automate sunt dezactivate
    WCBoost - Wishlist: version: 1.2.1, author: WCBoost, Actualizările automate sunt dezactivate
    WooCommerce: version: 10.0.2, author: Automattic, Actualizările automate sunt dezactivate
    WooCommerce Back In Stock Notifications: version: 3.3.0, author: Woo, Actualizările automate sunt dezactivate
    WooCommerce Oblio: version: 1.0.73, author: Oblio Software, Actualizările automate sunt dezactivate
    WP Rocket: version: 3.19.1.2, author: WP Media, Actualizările automate sunt dezactivate wp-server

    server_architecture: Linux 4.18.0-425.19.2.lve.el8.x86_64 x86_64
    httpd_software: LiteSpeed
    php_version: 8.2.28 64bit
    php_sapi: litespeed
    max_input_variables: 10000
    time_limit: 600
    memory_limit: 1024M
    max_input_time: 256
    upload_max_filesize: 256M
    php_post_max_size: 256M
    curl_version: 8.14.1 OpenSSL/1.1.1w
    suhosin: false
    imagick_availability: true
    pretty_permalinks: true
    htaccess_extra_rules: true
    static_robotstxt_file: true
    current: 2025-07-21T10:26:47+00:00
    utc-time: Monday, 21-Jul-25 10:26:47 UTC
    server-time: 2025-07-21T13:26:45+03:00 wp-database

    extension: mysqli
    server_version: 10.5.29-MariaDB-cll-lve
    client_version: mysqlnd 8.2.28
    max_allowed_packet: 268435456
    max_connections: 4000 wp-constants

    WP_HOME: undefined
    WP_SITEURL: undefined
    WP_CONTENT_DIR: /home/sexshopr/public_html/wp-content
    WP_PLUGIN_DIR: /home/sexshopr/public_html/wp-content/plugins
    WP_MEMORY_LIMIT: 1024M
    WP_MAX_MEMORY_LIMIT: 1024M
    WP_DEBUG: false
    WP_DEBUG_DISPLAY: false
    WP_DEBUG_LOG: true
    SCRIPT_DEBUG: false
    WP_CACHE: true
    CONCATENATE_SCRIPTS: undefined
    COMPRESS_SCRIPTS: undefined
    COMPRESS_CSS: undefined
    WP_ENVIRONMENT_TYPE: undefined
    WP_DEVELOPMENT_MODE: undefined
    DB_CHARSET: utf8mb4
    DB_COLLATE: undefined wp-filesystem

    wordpress: writable
    wp-content: writable
    uploads: writable
    plugins: writable
    themes: writable
    fonts: does not exist
    mu-plugins: writable

    Thank you!

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @danieldumitruavram,

    Thank you for sharing the details.

    This shouldn’t happen because we do call the function inside the init hook which should throw an error but it seems that something in particular on your website is delaying some code execution which causes this function to not be available when we try to call it.

    To have this issue sorted, please get in touch with our development team using the following email address: [email protected]

    Looking forward to helping you.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Fatal Error: Call to undefined function wp_get_current_user() in class-admin-men’ is closed to new replies.