{"id":23631,"date":"2013-06-09T12:27:08","date_gmt":"2013-06-09T12:27:08","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/redirect-to-login-if-not-logged-in\/"},"modified":"2018-09-13T09:18:51","modified_gmt":"2018-09-13T09:18:51","slug":"redirect-to-login-if-not-logged-in","status":"publish","type":"plugin","link":"https:\/\/tw.wordpress.org\/plugins\/redirect-to-login-if-not-logged-in\/","author":8535317,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.7.0","stable_tag":"1.7.0","tested":"5.0.25","requires":"3.0.1","requires_php":"","requires_plugins":"","header_name":"Redirect to login if not logged in","header_author":"Daan Kortenbach","header_description":"","assets_banners_color":"","last_updated":"2018-09-13 09:18:51","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"http:\/\/wordpress.org\/plugins\/redirect-to-login-if-not-logged-in\/","header_author_uri":"https:\/\/wppro.nl\/","rating":4.8,"author_block_rating":0,"active_installs":200,"downloads":20064,"num_ratings":10,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","changelog","faq"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":"1","4":0,"5":"10"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.2","1.3","1.4","1.5","1.6.2","1.6.3","1.7.0"],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[602,727],"plugin_category":[38],"plugin_contributors":[78541],"plugin_business_model":[],"class_list":["post-23631","plugin","type-plugin","status-publish","hentry","plugin_tags-login","plugin_tags-redirect","plugin_category-authentication","plugin_contributors-daankortenbach","plugin_committers-daankortenbach"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/redirect-to-login-if-not-logged-in.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Redirects users to the login page if the user is not logged in. After login the user gets redirected to the original entry page. For advanced users a filter is provided to override the redirect.<\/p>\n\n<p>The principle behind this plugin is to redirect all users - from every post, page, archive, etc. - to the login page (usually wp-login.php). Except for the override filter it does nothing else.<\/p>\n\n<h4>Overriding the redirect<\/h4>\n\n<ul>\n<li><strong>Note:<\/strong> This plugin may not be for you, a membership plugin might be a better fit. Chris Lema writes excellent reviews of +30 membership plugins here: http:\/\/chrislema.com\/category\/memberships-plugins\/<\/li>\n<\/ul>\n\n<p>If you do have a need for this plugin and you want to exclude specific views under specific conditions, a filter is provided to override the redirect.<\/p>\n\n<p>To override the redirect the filter must return a boolean value of <code>true<\/code>. WordPress core provides many conditional tags that either return <code>true<\/code> or <code>false<\/code> or you can write your own conditionals.<\/p>\n\n<p>Take a look at the Conditional Tags page on The WordPress Codex for some inspiration.\nhttps:\/\/codex.wordpress.org\/Conditional_Tags<\/p>\n\n<p><strong>Usage:<\/strong>\nCopy\/paste\/edit an example to the functions.php of your theme or create a new file in wp-content\/mu-plugins\/ if you do not wish to edit your theme.<\/p>\n\n<p><em>Note: Be carefull not to use multiple filters at the same time as that may cause unexpected results. Instead use multiple conditions in one filter.<\/em><\/p>\n\n<ul>\n<li><p>Override if the front page is either posts or a page:<\/p>\n\n<p>add_filter( 'rtl_override_redirect', 'is_front_page' );<\/p><\/li>\n<li><p>Override if the post is 'hello-world':<\/p>\n\n<p>add_filter( 'rtl_override_redirect', function() {<br \/>\n      return is_single( 'hello-world' );<br \/>\n    });<\/p><\/li>\n<li><p>Override if the page is 'sample-page':<\/p>\n\n<p>add_filter( 'rtl_override_redirect', function() {<br \/>\n      return is_page( 'sample-page' );<br \/>\n    });<\/p><\/li>\n<li><p>Override if the page ID is 42, the slug is 'sample-page' or the title is 'About Me':<\/p>\n\n<p>add_filter( 'rtl_override_redirect', function() {<br \/>\n      return is_page( array( 42, 'sample-page', 'About Me' ) );<br \/>\n    });<\/p><\/li>\n<li><p>Override if the page ID is 42 or a post is 'hello-world':<\/p>\n\n<p>add_filter( 'rtl_override_redirect', function() {<br \/>\n      if ( is_page( 42 ) || is_single( 'hello-world' ) ) {<br \/>\n        return true;<br \/>\n      }<br \/>\n    });<\/p><\/li>\n<\/ul>\n\n<!--section=installation-->\n<ol>\n<li>Upload <code>redirect-to-login-if-not-logged-in<\/code> to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<\/ol>\n\n<!--section=changelog-->\n<h4>1.7.0<\/h4>\n\n<ul>\n<li>Add redirect override filter.<\/li>\n<li>Add filter examples.<\/li>\n<\/ul>\n\n<h4>1.6.3<\/h4>\n\n<ul>\n<li>Fix svn repo.<\/li>\n<\/ul>\n\n<h4>1.6.2<\/h4>\n\n<ul>\n<li>Version file mismatch fix.<\/li>\n<\/ul>\n\n<h4>1.6.1<\/h4>\n\n<ul>\n<li>WordPress 4.2 compatibility update.<\/li>\n<\/ul>\n\n<h4>1.6<\/h4>\n\n<ul>\n<li>WordPress 4.1.1 compatibility update.<\/li>\n<\/ul>\n\n<h4>1.5<\/h4>\n\n<ul>\n<li>Complete rewrite to use the already existing auth_redirect hook.<\/li>\n<li>Strips '?loggedout=true' from redirect url after login.<\/li>\n<\/ul>\n\n<h4>1.4<\/h4>\n\n<ul>\n<li>Moved the conditionals to the init hook due to some edge cases not redirecting.<\/li>\n<\/ul>\n\n<h4>1.3<\/h4>\n\n<ul>\n<li>Plugin naming.<\/li>\n<\/ul>\n\n<h4>1.2<\/h4>\n\n<ul>\n<li>Releasing to the WordPress plugin repo.<\/li>\n<\/ul>\n\n<h4>1.1<\/h4>\n\n<ul>\n<li>Cleanup.<\/li>\n<li>Now using wp_login_url() in redirect.<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>Initial version.<\/li>\n<\/ul>\n\n<!--section=faq-->\n<dl>\n<dt>Installation Instructions<\/dt>\n<dd><ol>\n<li>Upload <code>redirect-to-login-if-not-logged-in<\/code> to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<\/ol><\/dd>\n\n<\/dl>","raw_excerpt":"Redirects users to the login page if the visitor is not logged in.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/23631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/tw.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/tw.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=23631"}],"author":[{"embeddable":true,"href":"https:\/\/tw.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/daankortenbach"}],"wp:attachment":[{"href":"https:\/\/tw.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=23631"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/tw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=23631"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/tw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=23631"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/tw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=23631"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/tw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=23631"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/tw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=23631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}