• Here’s the scenario:
    I’m using WP 2.5.1 and the SACK AJAX library to enable AJAX functions on a particular page on my site. Right now the file being called by the client side is not a file that is part of WordPress. Since the file on the server is not part of WP, I don’t have a way to access any WP information

    I would like the server side file to have access to the user’s account information.

    As far as I can tell, there a few ways to do this:
    1) Integrate my server side file (the one responding to the client’s AJAX request) part of WP. I don’t know how to do this, but it might be ideal.

    2) Figure out a way to give the existing server side file access to the WP users’ information. I could access the WP database easily enough, but I’d have no way of knowing which user is accessing the file.

    3) Use WP to put client ID information INTO the page which will be making the AJAX call and pass that client ID information back to the non-WP server side file which would allow it get info on the user. This is a clumsy and inelegent way of doing things.

    I would appreciate any insight into how you might solve this problem.

    Thank you,

    – H

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Haloscope

    (@haloscope)

    Well, I found something that helps! A little!

    <?php
    include_once('../../../wp-config.php');
    include_once(ABSPATH . 'wp-includes/functions.php');
    $info = get_option( 'blogdescription' );
    ?>

    Inserting this code at the top of a plugin will load up all the WP functions. This will let me access WP options information.

    Unfortunately, I can’t get access to other info yet – such as the current user’s ID. I’d appreciate any help on this.

    – H

    Inserting this code at the top of a plugin will load up all the WP functions.

    And thats overkill. Only one file needs to be included to use WP fucntions, wp-blog-header.php

    Thread Starter Haloscope

    (@haloscope)

    Thank you! I’ll try that! Do you have any idea how I would go about obtaining current user info from a file that’s outside WP?

    Thanks,

    – H

    i also has the similar needs: accessing $user_ID from an ajax call, from an admin plugin page.

    i noticed the function get_currentuserinfo() from /includes/pluggable.php accessing wp_validate_auth_cookie() — but including the file will be too complicated as it needs various variable and constants … ??

    ok, now i’m using a workaround by passing the $user_ID into session, and then read it again from my ajax request.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WP/AJAX question – How do I access a user’s ID info from outside WP?’ is closed to new replies.