wordpress plugin -> Call to undefined function wp_get_current_user()

后端 未结 9 1871
忘掉有多难
忘掉有多难 2020-12-01 07:58

I\'m trying to get the current user info in my plugin using the func wp_get_current_user(). But am getting Call to undefined function wp_get_current_user()

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 08:18

    After the installation of wp 3.8 I had the same problem with a page I get with ajax. I fixed it with the following code:

    if(!function_exists('wp_delete_user')) {
        include(ABSPATH . "wp-admin/includes/user.php.");
    }
    

    Apparently the function is moved from pluggable.php to user.php. Still I don't understand why it doesn't work after I included the wp-blog-header.php.

提交回复
热议问题