I've got custom developed sales system (in PHP, let's say it's domain.com) and I would like to add informational section to it. Instead of developing it from the ground up I thought that it would be better to publish information by Wordpress (for example published on subdomain infos.domain.com).

The problem is I would like to make it accessible only for users logged in to domain.com system. So when somebody enters infos.domain.com he sees some text like "Please login to domain.com". When somebody is logged in to domain.com he should be able to read all the pages in infos.domain.com. Commenting them is not necessary (read-only is enough).

As I know Wordpress rather from administrator's perspective I tried to find some plugin to solve that, but I failed. Maybe you can advice some ready-made (evan paid) solution? If it does not exist please, advise how it could be solved.

Login to domain.com is based on POST form and cookies, passwords in database are hashed with salt. domain.com system can be extended to provide some API.


Quick and dirty: add something that runs during the WordPress init action that checks your the domain.com login status, and dies if the person isn't logged in. At a very basic level (if you don't need a pretty "access denied" page or anything), you can do something as simple as this in a plugin:

function wpsx_26176_check_login() {

    // some logic to validate your cookies. here I'm just checking if a cookie exists
    // but obviously your validation would be more extensive
    if(!isset($_COOKIE['yourcookie'])) {
        wp_die('get out of here'); // If cookie is missing, just die

add_action('init', 'wpsx_26176_check_login');

What you'll need to keep in mind if rolling out WordPress on a subdomain is that cookies are by default only applicable to the domain they're set on. You'll have to set the cookies written by your custom application to specifically be available across all your subdomains.

  • Which Wordpress' .php file is the best to add such a code? – user7982 Aug 18 '11 at 15:10
  • You can put it in your theme's functions.php file. – MathSmath Aug 18 '11 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.