• Resolved Edward

    (@kamiyeye)


    recently i wrote a php script to handle an ajax request, but i cannot use wordpress function in it, it says “Fatal error: Call to undefined function get_userdata() in …”

    I guess it is because i didn’t include wordpress library, but these functions are always quietly loaded in normal php scripts such as header.php, functions.php, how do i load them manually?

Viewing 6 replies - 1 through 6 (of 6 total)
  • It sounds like your new function is a separate file correct? Can you include your new function in your theme’s functions.php?

    Thread Starter Edward

    (@kamiyeye)

    yes it is a separate file, i think i can try to include it to functions.php

    Thread Starter Edward

    (@kamiyeye)

    no use, i let ajax request post to functions.php, then all wp func in it return “Call to undefined function”

    any way you can post your function so someone can try it themselves?

    Thread Starter Edward

    (@kamiyeye)

    by letting the request post to index.php, the problem is gone, ??

    or you could add this line to the top of your separate file..
    <?php require('../../../wp-blog-header.php'); ?>

    that includes the wp environment into your page thus enabling wordpress functions to work.

    EDIT: I realized it’s a very old topic, sorry for bringing this thread up.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to resolve “Call to undefined function”?’ is closed to new replies.