Support » Plugin: Force Login » How to whitelist subdomain?

  • Resolved Alex Ford

    (@alexford)


    I’m setting up a Blog Network with WordPress Multisite using subdomains for blogs.

    The main site is elevatesites.com which goes to the login page. Just how I want it!

    However, I want to whitelist subdomains so that blogs under subdomains can still be viewed by the public.

    For example, http://*.elevatesites.com/ should be able to be viewed without logging in, and all relevant pages and posts too.

    Of course, the “*” should automatically be replaced with whatever subdomain blog is being viewed.

    I don’t know PHP, but I’m sure you’ll understand what I mean by the code below.

    /**
    * Filter Force Login to allow exceptions for specific URLs.
    *
    * @return array An array of URLs. Must be absolute.
    */
    function my_forcelogin_whitelist( $whitelist ) {
    $whitelist[] = ‘http://*.elevatesites.com/’;
    return $whitelist;
    }
    add_filter(‘v_forcelogin_whitelist’, ‘my_forcelogin_whitelist’, 10, 1);

    Can someone please give me advice on how to fix this?

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try uninstalling WordPress from the /wp directory, and install it to your main site. But first, backup your data, and plugins.
    If you were using a 1-click method of installing wordpress; follow these steps:

    1. Go to your hosting control panel. And locate the WordPress 1-click installer.
    2. Install it at your main site, leave the field where wp was at blank. If you see wp as a directory… clear the field. example: example.com/wp. Replace it with example.com/ without the wp suffix. or directory,–just like your site currently.
    3. Configure multisite to run via subdomains. Be sure to add an * at the subdomains area of your control panel first. After you have this setup, continue to the next step.
    4. Give your site a title, and description. And complete the install of your WordPress site.

    Why wildcard subdomains are required for these subsites via subdomains to work… see this article: http://news.fairiesdreamsfantasy.com/wordpress-multisites-via-subdomains-need-a-wildcard-subdomain-in-order-for-these-subdomain-based-sites-to-work/. Refer to the codex for getting help with creating a network at: https://codex.wordpress.org/Create_A_Network for help.
    If you implemented a forced login scheme… your entire website will NOT be public to anyone. And I see you disabled registration on your site altogether. If this is the case… go to your wordpress network control panel. And enable registration for your users. By default; all subsites, and the main sites are public to the entire web!
    If this post is helpful… please let me know.

    Plugin Author Kevin Vess

    (@kevinvess)

    I’m setting up a Blog Network with WordPress Multisite using subdomains for blogs. […] I want to whitelist subdomains so that blogs under subdomains can still be viewed by the public.

    Did you activate Force Login for the entire network on WordPress Multisite? You may just need to activate the plugin on a per-site basis.

    https://premium.wpmudev.org/manuals/wpmu-manual-2/activating-and-deactivating-plugins-on-a-per-site-basis/

    Thread Starter Alex Ford

    (@alexford)

    Hi Fairy-Rider and Kevin, thanks for the responses!

    I figure out what I needed… just needed the install the plugin on the MAIN SITE, and that was all.

    It was just the root domain that I wanted to Force Login on.

    Thank you!

    Plugin Author Kevin Vess

    (@kevinvess)

    Great! I’m glad you were able to resolve the issue.

    Be sure to rate and review my plugin to let others know how you like it.

    Thanks for using Force Login!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to whitelist subdomain?’ is closed to new replies.