Best way to add in a custom php page to wordpress? (2 posts)

  1. JohnW92
    Posted 3 years ago #

    Hi Guys,

    I am creating a booking system using wordpress.

    So once the user has completed the form it submits the data to the database and then I have built a custom php page to show the user their details - retrieved from the database. I just need to know how to integrate this into a wordpress page? Is there a way so I can make it only registered (signed in) users can view this page - how would I go about doing this?

  2. DavidGoliathGroup
    Posted 3 years ago #

    I'm assuming you have your own database for users, and people can register specifically for your site. If so did you make this?

    You can set a $_SESSION variable when a user successfully logs in such as $_SESSION['user_auth']. When the user logs in set this to one, when the session ends (browser closes) or they logout (depending how the logout function is setup you may have to unset user_auth on log out.

    Then you set that page to only allow visitors if the $_SESSION['user_auth'] variable is set to one.

    if ($_SESSION['user_auth'] == 1){
        execute your custom page (wrap this if statement around your entire code)
    else {
        redirect to login page

Topic Closed

This topic has been closed to new replies.

About this Topic