Last active
September 1, 2023 09:41
-
-
Save PluginRepublicSupport/19985cd9c7b5621f67f2f32159bd4fd5 to your computer and use it in GitHub Desktop.
Allow the translated version of a login page to be viewed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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