Title: Documentation Error
Last modified: September 23, 2019

---

# Documentation Error

 *  Resolved [iNexi](https://wordpress.org/support/users/inexi/)
 * (@inexi)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/documentation-error-4/)
 * I believe there is a bug in the example for a Custom Login Page. The `exit;` 
   should be contained within the `if` statement. As written it causes a Custom 
   Login page to never redirect back to the oAuth client site.
 * A second bug in the same example regards the `redirect_to` query variable. The
   URL should be URL encoded, since there will be multiple query variables with 
   every credential auth redirect.
 * Here’s my working, updated code:
 *     ```
       //Redirect a user to a custom login page for authentication
       add_action( 'wo_before_authorize_method', function () {
       	if ( ! is_user_logged_in() ) {
       		wp_redirect( site_url() . '/custom-login/?redirect_to=' .urlencode( site_url() . $_SERVER['REQUEST_URI'] ) );
       		exit;
       	}
       });
       ```
   
 * This affects the Docs page, and the examples.php file.
    -  This topic was modified 6 years, 8 months ago by [iNexi](https://wordpress.org/support/users/inexi/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fdocumentation-error-4%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Plugin Author [Justin Greer](https://wordpress.org/support/users/justingreerbbi/)
 * (@justingreerbbi)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/documentation-error-4/#post-11971352)
 * Thank you for your effort and thank you for reporting this. I have updated both
   instances of the example code.

Viewing 1 replies (of 1 total)

The topic ‘Documentation Error’ is closed to new replies.

 * ![](https://ps.w.org/oauth2-provider/assets/icon-256x256.gif?rev=2603051)
 * [WP OAuth Server (OAuth Authentication)](https://wordpress.org/plugins/oauth2-provider/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/oauth2-provider/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/oauth2-provider/)
 * [Active Topics](https://wordpress.org/support/plugin/oauth2-provider/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/oauth2-provider/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/oauth2-provider/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Justin Greer](https://wordpress.org/support/users/justingreerbbi/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/documentation-error-4/#post-11971352)
 * Status: resolved