{"id":11960573,"date":"2019-09-23T15:39:29","date_gmt":"2019-09-23T15:39:29","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/documentation-error-4\/"},"modified":"2019-09-23T15:39:55","modified_gmt":"2019-09-23T15:39:55","slug":"documentation-error-4","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/documentation-error-4\/","title":{"rendered":"Documentation Error"},"content":{"rendered":"<p>I believe there is a bug in the example for a Custom Login Page. The <code>exit;<\/code> should be contained within the <code>if<\/code> statement. As written it causes a Custom Login page to never redirect back to the oAuth client site.<\/p>\n<p>A second bug in the same example regards the <code>redirect_to<\/code> query variable. The URL should be URL encoded, since there will be multiple query variables with every credential auth redirect.<\/p>\n<p>Here&#8217;s my working, updated code:<\/p>\n<pre><code>\/\/Redirect a user to a custom login page for authentication\nadd_action( &#039;wo_before_authorize_method&#039;, function () {\n\tif ( ! is_user_logged_in() ) {\n\t\twp_redirect( site_url() . &#039;\/custom-login\/?redirect_to=&#039; .urlencode( site_url() . $_SERVER[&#039;REQUEST_URI&#039;] ) );\n\t\texit;\n\t}\n});<\/code><\/pre>\n<p>This affects the Docs page, and the examples.php file.<\/p>\n","protected":false},"template":"","class_list":["post-11960573","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11960573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11960573\/revisions"}],"predecessor-version":[{"id":11960575,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11960573\/revisions\/11960575"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=11960573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}