How To Exclude The Pages/Posts From Force Login Feature (Hook)

Are you wondering how to exclude the pages and posts from the "force login" feature in WordPress? If so, then this post is for you. 

Force Login is a premium feature of LoginPress. It forces users to log in before viewing the contents of your site. When you enable the option of Force Login, a user will be redirected to the login page to log in before viewing your site’s content. 

It is designed to create a membership feel to your WordPress site, making users Login to get inside the WordPress website.

Force Login - LoginPress's Pro Feature
Force Login - LoginPress's Pro Feature

You can learn more about the Force Login feature to understand its working.

But what if you don’t want to apply the Force Login condition to some specific pages, i.e., Exclude those pages allowing users to barge in to see the content?

You can exclude those pages/posts from the Force Login feature to quickly engage and improve the user’s experience.

So let’s begin to know how it can be done! 

Exclude The Pages/Posts from Force Login Feature with Hook

Suppose you want to exclude the specific pages or posts (like the Privacy Policy page or any other specific post or page) from the LoginPress Force Login feature means if a user wants to view any page or post content, then they don't need to log into the website/blog in order to see it.

To exclude the specific pages or posts from the Force Login, you need to add the following line of code in your Child Theme's file functions.php and update the file. 

function loginpress_exclude_forcelogin_callback() { return array( 
'privacy-policy', '1' ); //Here '1' is the ID of the 
'loginpress_exclude_forcelogin_callback' );

Too Difficult?

Here is an explanation of what this is, Here ‘privacy-policy’ is the slug of a post or page and ‘1’ is the ID of the post/page. It means you can give both slugs and IDs of post/page in this comma-separated array.

Slug of post or post-id.

Note: To return a single value or array. You can return the slug of the post or the post-id. With the help of the loginpress_exclude_forcelogin hook, you can prevent pages/posts from Force Login features.

That’s all!

You can exclude posts and pages from the Force Login feature of LoginPress using the hook provided above.

If you have any doubts or questions related to it, please don’t hesitate to reach out to our support forum. We will be happy to help you with it.

Still stuck? How can we help?

Updated on October 25, 2022

LoginPress Support
triangular shape yellowish icon

Frequently Asked Questions (FAQs)

These FAQs answer the most common questions about our WordPress custom login page plugin.

three shapes icon

Is LoginPress WPML Compatible?

LoginPress is fully supported with multilingual. LoginPress is also compatible with WPML Plugin, which means you can easily translate your login page with WPML plugin according to the given translation options in the WPML plugin.

Is LoginPress translation ready?

Yes, LoginPress has full translation and localization support via the LoginPress textdomain. All .mo and .po translation files should go into the languages folder in the base of the plugin.

Is coding skills needed to use LoginPress?

No, It is very easy to setup. Just plug and play. Have fun!

How to Install or Use LoginPress Pro?

Step-by-step instructions on How to Upgrade from existing Free version to Pro
1. You have installed and set up the Free version already.
2. Upload the Pro version.
3. Pro features will be enabled automatically.
4. You don’t need to set up Free version options again.
5. Setup Pro features like Google fonts, Google reCaptcha, Choose themes, etc.

Where is my license key?

License key is the Order ID which looks like in this format.
You can find it in the email Sales Receipt.

three shapes icon

If you Still have Questions?

Get In Touch