Forums

How to call WP functions from outside WP? (3 posts)

  1. spstieng
    Member
    Posted 2 years ago #

    Hi.

    I'm developing a plugin (myPlugin.php) and have added the following lines in this file:

    global $current_user;
      get_currentuserinfo();

    This allows me to access e.g. $current_user->ID from myfile.php

    I'm using jQuery.post to call a php file (lets call it test.php).
    Inside test.php I'm trying to get $current_user->ID, but I get zero results. If I try adding get_currentuserinfo(), I get a message saying that is doesn't know the function get_currentuserinfo().

    So how can I retrieve user info from test.php which is called from jQuery.post?

  2. MichaelH
    Volunteer
    Posted 2 years ago #

  3. spstieng
    Member
    Posted 2 years ago #

    Brilliant! Thanks Michael.
    I will test this and see how it goes and post the result.

Topic Closed

This topic has been closed to new replies.

About this Topic