• Resolved sungyong

    (@sungyong)


    I’m trying to integrate wordpress and other system has it’s own user db.
    I managed to integrated login with external_db_authenticate plugin.
    Then extend more information to user_meta table.

    To share login information between wordpress and another, I decided to use local storage.

    step is below.
    1. after wp_authenticate, store user information to local storage
    2. other system read local storage.

    But stuck with 1st step.
    How can I storage key, value to local storage after wp_authenticate.
    Is is possible to call javascript in that step?

    Thanks for reading. Any advice will be helpful for me.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    JavaScript will not run on your server, only within client browsers. You could have the browser send data via Ajax, but you still need PHP to process the request.

    You should be able to still use the “authenticate” filter to save data. You can use WP functions if the data is destined for WP tables, or use $wpdb methods to save in custom tables. Hook “authenticate” with a large priority number to help ensure your callback executes after authentication, evidenced by the first passed parameter being a WP_User object. This is assuming that your authentication plugin still respects the normal WP authentication routine. There’s no reason it wouldn’t, but plugins often do strange, unusual things.

    If a late “authenticate” hook doesn’t work for some reason, you could try “wp_login” action, but it may not work either if the plugin subverts the normal log in process. If that’s the case, you should inquire with the plugin developers because they are most familiar with how their authentication process works. The plugin may have its own hooks or some other way of extending functionality.

    Thread Starter sungyong

    (@sungyong)

    @bcworkz
    Thank you for reply.

    Actually, authentication is processed by wordpres plugin by connect sqlserver directly.
    So wordpress’s authenticate was finished. But other system using sqlserver doesn’t know it.

    So my approach is sharing login information by browser’s local storage. But as you said, this is handled by browser not by php at wordpress.
    To make Ajax page, and invoke it at wordpress plugin is the best for that?

    Moderator bcworkz

    (@bcworkz)

    Ajax will certainly do the job. Whether it’s the “best” or not is hard for me to say because I don’t have the entire picture of what’s going on. If the data is client side and needs to be server side; and it cannot be transmitted during some other normal data exchange, then it’s very likely the best approach ??

    Ajax in WP has a few quirks beyond normal Ajax techniques. The Plugin Handbook lines out the basics.

    Thread Starter sungyong

    (@sungyong)

    As you mentioned, Ajax techniques in WordPress will be helpful for me.
    I’m really appreciate for your advice.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘save to local storage after authenticate’ is closed to new replies.