• Hi all, on my first adventure in WP plugin development and need some guidance and expertise from the gurus. I’ve made some headway into integrating WordPress with another PHP app with the intent to use WordPress as a CMS.

    I’m a little torn on what strategy to use for integrating the userbases of the two platforms.

    For right now, I’m essentially just running wp_create_user and storing redundant information in the WP database which includes user metadata that syncs with the user ID of the other app. However, the idea of keeping two copies of essentially same data bugs me.

    So I’m wondering what other strategies exist for user integration between systems.

    Is there a way to “override” or custom map the WP_User where I can put an interface or filter in front of WP_user so that whenever WordPress attempts to get user information, it goes through my custom interface so that I can manipulate the data as needed (and by this I mean just mapping the data from the other app to match what WP_User properties)?

    I was thinking about extending WP_User class but then I’m still unsure how I could plug the new class into everything.

    I was able to do this with comments by using the ‘comments_array’ filter to create my own stdClass object to return but I couldn’t find any filters for the user data.

    Appreciate any pointers! Thanks!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    There’s a number of possibilities. What you do depends on how much you need the native WP user system. If you don’t need it at all, you just need the one WP admin user, everyone else is authenticated through the other app, and what the WP frontend displays is based on a custom user rights function used on the various theme templates.

    If you need more WP user functionality, WP users need at least a username and email. These can match those in the other app, you are going to have to live with this much redundant data. It should be possible to keep this data synced with some custom code that changes the other app’s data when it’s changed in the current app.

    All other data only needs to reside in one place or the other. Some sort of user relationship needs to be maintained in order for one app to be able to get data from the other app. This could just be the other app’s user ID stored in WP’s user meta. Some sort of API would need to be developed to be able to query the other app for user data as needed.

    There isn’t much to gain by extending the WP_User class because WP will still need to use it’s own class, you cannot force it to use your version. There is indeed no filter to alter this need. There are numerous filters though when doing more specific tasks, for example when a user updates their profile, an action fires that you can hook so that any data that was changed by the user that is stored in the other app can be sent to the other app for updating that DB. WP might store some of the same data anyway, but you don’t need to make use of it, it’s just there. Anytime the data is actually needed, it is retrieved from the remote DB via some filter or action hook.

Viewing 1 replies (of 1 total)
  • The topic ‘Is there a way to override or map WP_User ?’ is closed to new replies.