Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

redirection not working with wpml

$
0
0

Replies: 1

Hi,

Originally the site was not multilingual.
I made a code snippet so only logged in users could see the store page (https://www.treeclix.com/store), otherwise they would be redirected to the account page to login.
This is the still working code snippet:

add_action( 'template_redirect', 'redirect_to_specific_page' );

function redirect_to_specific_page() {

if ( is_page('store') && ! is_user_logged_in() ) {

wp_redirect( 'https://www.treeclix.com/my-account/', 301 ); 
  exit;
    }
}

I installed WPML and cloned the snippet.
I first changed the check for store to ‘winkel’ and also to the ID 715, but this snippet is not working:

add_action( 'template_redirect_nl', 'redirect_to_specific_page_nl' );

function redirect_to_specific_page_nl() {

if ( is_page( 715 ) && ! is_user_logged_in() ) {

wp_redirect( 'https://www.treeclix.com/nl/mijn-account/', 301 ); 
  exit;
    }
}

Viewing all articles
Browse latest Browse all 59525

Trending Articles