Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Added an exception to allow WordPress XML-RPC remote publishing while my Force Login plugin is activated.
function v_forcelogin() {
$url = v_getUrl();
if( !is_user_logged_in() && preg_replace('/\?.*/', '', $url) != preg_replace('/\?.*/', '', wp_login_url()) ) {
if( substr(preg_replace('/\?.*/', '', $url), -10) != 'xmlrpc.php' ) {
wp_safe_redirect( wp_login_url( $url ), 302 ); exit();

This comment has been minimized.

Copy link
Owner Author

commented Jun 30, 2016

This gist example is no longer valid.

As of Force Login version 3.0 – you can whitelist the xmlrpc.php URL to allow remote publishing by adding the following code to your theme's functions.php file:

 * Filter Force Login to allow exceptions for specific URLs.
 * @return array An array of URLs. Must be absolute.
function my_forcelogin_whitelist( $whitelist ) {
  $whitelist[] = site_url( '/xmlrpc.php' );
  return $whitelist;
add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.