• Resolved candidek

    (@candidek)


    Hi – we’re looking to use ReactPress to build a web app within a WordPress membership website. The React app needs to be aware of the ID of the current logged in user. What is the best way to pass this from WordPress to the React app?

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author rockiger

    (@rockiger)

    There is one global js variable ‘reactPress’. It has two properties user and usermeta.

    If the user is logged in, the holds the user data, otherwise, they are empty.

    Hi! Thanks for the answer, but how do I access the variable? Something like process.env.reactPress?
    thanks!

    Plugin Author rockiger

    (@rockiger)

    window.reactPress

    @rockiger

    I am using windows.reactPresson react app but I got an undefined value, can you please help me with anything I need to do to get a WordPress user id on reactPress app?

    See this screenshot https://prnt.sc/WUNMSsu-PX73

    • This reply was modified 2 years, 3 months ago by Mahesh Patel.
    • This reply was modified 2 years, 3 months ago by Mahesh Patel.
    • This reply was modified 2 years, 3 months ago by Mahesh Patel.
    • This reply was modified 2 years, 3 months ago by Mahesh Patel.
    Plugin Author rockiger

    (@rockiger)

    Ah, ok.

    On localhost:3000 (the React dev server) you need to mock the user. The user is only available on a real WordPress installation.

    @rockiger

    I didn’t understand what you say, what is real wordpress installation?
    How the issue will resolve?

    That means it didn’t work on local system.

    Please clarify in detail.

    Thanks
    Mahesh

    Plugin Author rockiger

    (@rockiger)

    Your screenshot shows only the create-react-app dev server (localhost:3000). Not a wp installation, not local, not productive.

    ReactPress simulates the theme of your wp installation for a better development experience when you use the cra dev server.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Identify current user’ is closed to new replies.