WordPress.org

Ready to get started?Download WordPress

Forums

How To "If User is Logged In/Out" from External Sser DB (2 posts)

  1. AMEEKER
    Member
    Posted 9 months ago #

    We've just begun a project where the users are not in the WP database, but are part of a separate database. We need to display content based on whether those users are logged in or logged out (which they do on a portion of the site that is connected to that other database - that portion of the site is not WP). On the WP portions, how can check to see if the users are logged in for the purpose of displaying different content? I know how to solely within WP, but not when the users are external.

  2. bcworkz
    Member
    Posted 9 months ago #

    You will need to use PHP mysqli functions to connect to that DB and query for the information you need. The mysqli class is similar to the WordPress wpdb class, except you need to create your own object and establish a connection, which is done for you when you use $wpdb.

    There's lots of information on the 'net about generic mySQL queries from PHP, but they typically use the older mysql_*() functions. mysqli is a newer implementation that has parallel functions, so translating old to new code should be straight forward.

Reply

You must log in to post.

About this Topic