• Hello All –

    I have set up a WordPress blog on a website that requires users to login for access. The site itself is not WordPress, just the blog that is set up in its own sub-directory. Currently you can view the blog whether you are logged in or not by calling up the direct URL.

    This is for the company I work for and I now have been asked to set up the blog so that it is only visible to users when they are logged into the main site. I have looked for a solution and so far haven’t found one. Is there a way for WordPress to tell if a user is logged into the main site and, if they are not, redirect them to the main login page if they try to call up the blog URL?

    Also, do not want people to have to create accounts on the blog, just to be able to use their existing accounts from the main site to view the blog.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You mention that:

    The site itself is not WordPress

    Whatever the solution is will depend on how the main site is build and what it is built upon. WordPress can tell if a user is logged into WordPress but to tell if someone is logged in from another system would probably require some kind of custom development.

    What is the main site built on or with?

    Depending on the system powering the main site you might look around for a user bridge to connect your WordPress to that.

    If your main site is WordPress based then there is documentation out there to share the main site’s user base with the blog’s user base. Not the easiest setup but once done and sessions shared it works seamlessly.

    Most blogs are publically available with the ability to make/mark a few select posts as ‘private’ requiring a password to see. That way the blog is an added publication and promotional channel. Of course, the users might resent being locked out of certain posts.

    Thread Starter SqrlGrl

    (@sqrlgrl)

    The main site is PHP. I’m wondering if there might be a PHP function that can be put on the functions.php file that can link to the main database?

    And I am not a PHP programmer but work with two of them so if needed they can help me out.

    Thanks for your quick reply!

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Moved to Fixing WordPress, this is not a Developing with WordPress topic.

    So it sounds like you’re trying to have users be logged into WordPress whenever they log into your PHP website. It’s a bit of a developmental task to get it done, I would suggest your developers try to work with:

    https://www.ads-software.com/plugins/onelogin-saml-sso/

    Additionally, this Auto Login tutorial may be helpful. It suggests that you’ll need to set the wp_set_auth_cookie() cookie whenever your users log in through the other website.

    The developers may also be able to leverage the pluggable authentication functions as mentioned by Pat J on WordPress Stack Exchange.

    It’s going to be developmental work for your team to link the two sites.

    Thread Starter SqrlGrl

    (@sqrlgrl)

    Thank you for pointing me towards some possible solutions!

    I will take a look at these – thanks again!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WordPress blog visible to logged in users only?’ is closed to new replies.