Skip to content

Instantly share code, notes, and snippets.

@PluginRepublicSupport
Last active September 1, 2023 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PluginRepublicSupport/19985cd9c7b5621f67f2f32159bd4fd5 to your computer and use it in GitHub Desktop.
Save PluginRepublicSupport/19985cd9c7b5621f67f2f32159bd4fd5 to your computer and use it in GitHub Desktop.
Allow the translated version of a login page to be viewed
<?php
function custom_wcmo_is_content_restricted( $is_restricted, $restricted_content ) {
if ( $is_restricted ) {
// if Restriction Method is User Role, get the value of "If Restricted, Redirect To", usually the login page
$redirect_page = get_option( 'wcmo_redirect_restricted', false );
if ( $redirect_page ) {
// get the translated ID for the login page using WPML's filter
$redirect_page_translated = apply_filters( 'wpml_object_id', $redirect_page, 'page', false );
if ( get_the_ID() == $redirect_page_translated ) {
// we are on the translated page, allow this
$is_restricted = false;
}
}
}
return $is_restricted;
}
// You can use this filter to allow other pages
add_filter( 'wcmo_is_content_restricted', 'custom_wcmo_is_content_restricted', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment