Answers.Body: <p>A solution is to restrict access to the WordPress page that you are inserting the directory short code into. A plugin such as 'Members' allows you to restrict access to pages &amp; posts by user role, customize the message visitors see when they do not have permission and provide a login widget.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-15T15:49:13.547Z
Answers.Text: I've tried that plugin and another to attempt this, but the error comes up regardless of whether or not anonymous users are restricted. I also tested with hijack true and false and the result is the same.
Answers.UserDisplayName: Tomulent
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-15T16:08:14.043Z
Answers.Text: I have a similar setup and the page is restricted to two different roles. When someone is not logged in they get the error specified in WordPress here: Settings>Members>Content Permissions. Content permissions are enabled.
Answers.UserDisplayName: KilakwaBT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-15T18:18:41.850Z
Answers.Text: I'm not sure what I'm doing wrong but I cannot get this plugin to work. Anonymous users still get the old `Sorry but we are not able to provide this at the moment.` error—no content from the Members plugin appears.
Answers.UserDisplayName: Tomulent
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-15T20:59:14.933Z
Answers.Text: Just want to double check on the page that you have the directory short code on, do you have permissions set to only allow access to specific roles. The plugin should add a box for permissions on the lower part of the edit section of that page. You may want to remove the CiviCRM content to work on the permission issue first and then drop in the CiviCRM content.
Answers.UserDisplayName: KilakwaBT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-16T15:59:22.983Z
Answers.Text: Yes I have permissions set up correctly. There is no configuration that produces the desired result. This must be a CiviCRM setting.
Answers.UserDisplayName: Tomulent
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-16T16:04:49.283Z
Answers.Text: OK, Check the WordPress Access Control permissions for your user role. You can find them here: Administer>Users and Permissions > Permissions (Access Control) . Look at Profile Listings permission. May have to try a couple permission combinations.
Answers.UserDisplayName: KilakwaBT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-15T11:46:44.443Z
Answers.LastActivityDate: 2017-08-15T11:46:44.443Z
Answers.UserDisplayName: KilakwaBT
Body: <p>I'm using WordPress. I'm setting up various directory pages for registered users at URLs like <code>mysite.org/directory</code>. If a user is not logged in and navigates to that address they'll get:</p>
  
  <p><a href="https://i.sstatic.net/SqacE.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/SqacE.png" alt="enter image description here"></a></p>
  
  <p>This message is not useful to users. I would like instead for something like an automatic redirect of anonymous visitors to <code>wp-login.php</code>. Or failing that, simply change the link "Return to home page" with a link to the user login page.</p>
  
  <p><strong>More Info</strong>: Using a plugin to restrict access to profiles to logged-in users does not work as the Civi error overrides any page permissions. This is true regardless of the hijack content option.</p>
  
  <p>Also checked out the <a href="https://github.com/eileenmcnaughton/nz.co.fuzion.pageredirect" rel="nofollow noreferrer">page redirect extention</a> but it doesn't appear to be for WP.</p>
  
Tags: <wordpress><error-page><system-workflow-messages>
Title: How can I automatically redirect anonymous users to a login page?
ThreadText: # How can I automatically redirect anonymous users to a login page?
  
  (Asked by: username_0 on 2017-08-14)
  
  I'm using WordPress. I'm setting up various directory pages for registered users at URLs like `mysite.org/directory`. If a user is not logged in and navigates to that address they'll get:
  
  [![enter image description here](https://i.sstatic.net/SqacE.png)](https://i.sstatic.net/SqacE.png)
  
  This message is not useful to users. I would like instead for something like an automatic redirect of anonymous visitors to `wp-login.php`. Or failing that, simply change the link "Return to home page" with a link to the user login page.
  
  **More Info**: Using a plugin to restrict access to profiles to logged-in users does not work as the Civi error overrides any page permissions. This is true regardless of the hijack content option.
  
  Also checked out the [page redirect extention](https://github.com/eileenmcnaughton/nz.co.fuzion.pageredirect) but it doesn't appear to be for WP.
  
  **Tags:** wordpress, error-page, system-workflow-messages
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-08-15. Score: 1
  
  A solution is to restrict access to the WordPress page that you are inserting the directory short code into. A plugin such as 'Members' allows you to restrict access to pages & posts by user role, customize the message visitors see when they do not have permission and provide a login widget.
  
  > **Comments:**
  > **username_0**: I've tried that plugin and another to attempt this, but the error comes up regardless of whether or not anonymous users are restricted. I also tested with hijack true and false and the result is the same.  
  > **username_1**: I have a similar setup and the page is restricted to two different roles. When someone is not logged in they get the error specified in WordPress here: Settings>Members>Content Permissions. Content permissions are enabled.  
  > **username_0**: I'm not sure what I'm doing wrong but I cannot get this plugin to work. Anonymous users still get the old `Sorry but we are not able to provide this at the moment.` error—no content from the Members plugin appears.  
  > **username_1**: Just want to double check on the page that you have the directory short code on, do you have permissions set to only allow access to specific roles. The plugin should add a box for permissions on the lower part of the edit section of that page. You may want to remove the CiviCRM content to work on the permission issue first and then drop in the CiviCRM content.  
  > **username_0**: Yes I have permissions set up correctly. There is no configuration that produces the desired result. This must be a CiviCRM setting.  
  > **username_1**: OK, Check the WordPress Access Control permissions for your user role. You can find them here: Administer>Users and Permissions > Permissions (Access Control) . Look at Profile Listings permission. May have to try a couple permission combinations.  
  
  ---
  
  