WordPress.org

Ready to get started?Download WordPress

Forums

Fatal error: Call to undefined function wp_get_current_user() (32 posts)

  1. TQO23
    Member
    Posted 3 years ago #

    Hi.

    I have a new site that I'm building, have added in a new Talian theme and all was OK. Went to add the Web Traffic Genius RSS plugin by uploading a zip file.

    As soon as it started to install I received the following error message:

    Fatal error: Call to undefined function wp_get_current_user() in /home/alwinsi1/public_html/healthyinsights.co.uk/wp-includes/capabilities.php on line 1059

    I read another post on this forum that mentioned something about adding require_once(‘pluggable.php’); but I don't know anything about this type of coding so don't know where to start. I'm fine with editing the capabilities php file if someone knws how to overcome this.

    The post can be found at: http://wordpress.org/support/topic/fatal-error-call-to-undefined-function-wp_get_current_user-3?replies=4

    Would it be the new plugin I'm trying to load that's causing the problem?

    Any help appreciated.

    Regards

    Nigel

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Try re-uploading the wp-includes folder from a fresh download of WordPress. wp_get_current_user has been in core since 2.0.1

  3. Steve
    Member
    Posted 3 years ago #

    Esmi - the problem isn't that it isn't there. Its that current_user_can is being called by the plugin and for some reason although capabilities.php has been loaded (which contains the current_user_can function) that function calls wp_get_current_user which is defined in pluggable.php but hasn't been loaded when the call is made

    I think its actually a bug in WordPress - the solution is to add a require_once call to the top of capabilities.php.

  4. TQO23
    Member
    Posted 3 years ago #

    Hi Guys and thanks for your inuput.

    You are right Steve it was the "require_once" bit of code that was missing. Received an answer from the plugin coder and he confirmed that this was the case.

    They've included a note in their installation pdf files now.

    Thanks
    for your responses.

    regards

    Nigel

  5. sxpiv
    Member
    Posted 3 years ago #

    Hi Steve!

    I have a same problem weeks ago whit my new wordpress site.
    Do you said,that a solution is:

    "I think its actually a bug in WordPress - the solution is to add a require_once call to the top of capabilities.php. "

    Im not really a developer.can you explane it for me,that how can i do it?
    Thanks Zoltan

  6. sxpiv
    Member
    Posted 3 years ago #

    Actually is looking like this:"Fatal error: Call to undefined function wp_get_current_user() in D:\Program Files\xampp\htdocs\wp-includes\user.php on line 254" after i want install a new plugin,which already works in other websites.
    but wont work on my:(

  7. Steve
    Member
    Posted 3 years ago #

    You open capablities.php and add require_once(‘pluggable.php’);
    (but you need to change those quotes to single quotes) right after the opening <?php tag at the top of the file.

    The reason I say its a bug is that there is no way we should get to the point that capabilities has been loaded but pluggable hasn't.

  8. sxpiv
    Member
    Posted 3 years ago #

    Hi SteveAtty!"You open capablities.php and add require_once(‘pluggable.php’);" its works:)Thank you!
    but im not really understad,that what i have to do whit this"(but you need to change those quotes to single quotes) "
    Thanks Zoltan

  9. Steve
    Member
    Posted 3 years ago #

    If you cut and paste that line from in her then the quotes will be wrong so you need to change them to proper single quotes or you'll get an error

  10. LJagermaster
    Member
    Posted 3 years ago #

    Cheers Steve! Just came across that issue myself when trying to install a couple of "attendance" plugins (after this issue occurred with the first one I deleted and tried the second with the same issue re-occurring)...tried your fix and everything seems fine now :-D

    Oh, and sxpiv - just to clarify, what Steve means about the quotes marks (that surround the pluggable.php portion of the code), if you simply copy/paste it from this page, you'll notice that they appear at an angle as they do above, and this can muck things up, so if you highlight each of them and hit the single quote button (normally the second button to the left of the "Enter" button, and usually has the @ symbol floating above it) you should see that the angled quotes are replaced by vertical ones - ie. like this one -> '

  11. suziwilson
    Member
    Posted 3 years ago #

    I have the same problem but when I added the code to my capabilities.php (and update the tick marks) it says I don't have permission to access the Network Admin panel.

    What gives?

    Nothing seems to be working for me lately and I'm getting extremely frustrated. Any help would be appreciated.

  12. sxpiv
    Member
    Posted 3 years ago #

    Hi suziwilson!How did you but the code in your capabilities.php?

    <?php
    /**
    * WordPress Roles and Capabilities.
    *
    * @package WordPress
    * @subpackage User
    */
    require_once('pluggable.php') ?>

    Like this?

  13. suziwilson
    Member
    Posted 3 years ago #

    I have this below and now I get a full screen of the capabilities.php in text all scrunched together. :(

    <?php
    /**
    * WordPress Roles and Capabilities.
    *
    * @package WordPress
    * @subpackage User
    */
    require_once('pluggable.php') ?>
    /**
    * WordPress User Roles.

  14. johanhburger
    Member
    Posted 3 years ago #

    Is there some pace I can get an idiot's guide as to what you are talking about? My blog crashed after an amazon associate update, and I cannot get access to my blog!

  15. sxpiv
    Member
    Posted 3 years ago #

    suziwilson!
    After this line require_once('pluggable.php') ?>
    You should but there a php open tag.
    So it should looks like this
    <?php
    /**
    * WordPress Roles and Capabilities.
    *
    * @package WordPress
    * @subpackage User
    */
    require_once('pluggable.php') ?>
    <?php
    /**
    * WordPress User Roles.
    if you want,i can send you my capabilities php file.maybe it could help for you.

    sxpiv

  16. sxpiv
    Member
    Posted 3 years ago #

    johanhburger!
    Did you made security file and DB backup before did you update your site?
    sxpiv

  17. suziwilson
    Member
    Posted 3 years ago #

    sxpiv, Yes please send me a copy of your capabilities.php file. I will let you know how it works.

    Thanks again.

    suziwilson@q.com

  18. johanhburger
    Member
    Posted 3 years ago #

    unfortunately not. It was an automatic update.

  19. spacetime
    Member
    Posted 3 years ago #

    It seems I have found what causes problem in network mode but not why it is causing a problem.

    On my plugin the problem was because there was a file called settings.php. After renaming it to something else the error disappeared!

    I just don't know why settings.php causes error in network mode.

  20. johanhburger
    Member
    Posted 3 years ago #

    Thanks guys, I eventually managed to get into my host and the plugins. Deleted amazon associate plugin. My site is back up!

  21. sxpiv
    Member
    Posted 3 years ago #

    Johan.Great.I Hope that it will work well.

  22. suziwilson
    Member
    Posted 3 years ago #

    Is there some way to just fix the code here where the error is occurring? The error line is right after the $post = get_post($args[0]);

    case 'read_post':
    case 'read_page':
    $author_data = get_userdata( $user_id );
    $post = get_post( $args[0] );

    if ( 'revision' == $post->post_type ) {
    $post = get_post( $post->post_parent );
    }

  23. sxpiv
    Member
    Posted 3 years ago #

    suzi,the file already sent to your mail address
    sxpiv

  24. sxpiv
    Member
    Posted 3 years ago #

    suzy.
    from where did you get this code?

  25. suziwilson
    Member
    Posted 3 years ago #

    Hi sxpiv,
    Thank you for the capabilities.php. I uploaded it and I still get the error:
    You do not have permission to access this page.

    The excerpt I sent earlier is from the lines showing in error in the capabilities.php.

    I'm stuck. Nothing is working.

    Suzi

  26. sxpiv
    Member
    Posted 3 years ago #

    I'm said.I'm sorry,that i wasn't able to help you:(
    sxpiv

  27. suziwilson
    Member
    Posted 3 years ago #

    sxpiv, I did not resolve the reason for the issue, but I have resolved the immediate problem. I went into cpanel and renamed the Nivo Slider php plugin which caused the problem in the first place.

    That let me into the Network section where I deleted the plugin.

    Thanks for your efforts. MUCH appreciated!

    Suzi

  28. sxpiv
    Member
    Posted 3 years ago #

    Suzi!

    I'm said,that i wasn't able to help you directly,but if you have any question in the future,don't hesitate, just let me know,because maybe i can help you neather.

    sxpiv

  29. changedmyworld
    Member
    Posted 3 years ago #

    @johanhburger How did it just start working again? I'm having the same problem.

  30. suziwilson
    Member
    Posted 3 years ago #

    Hi Johanhburger,
    I suspected that the last plugin I installed may have caused the problem so I went into cpanel on my server and renamed the subdirectory for the plugin. In my case it was the Nivo Slider plugin.

    That allowed me to get back into the Admin panel where I deleted the plugin.

    Hope this helps you.

Topic Closed

This topic has been closed to new replies.

About this Topic