redirect to login page if user is not logged in
-
i want to let the user to add items to wishlist only if they are logged in otherwise they should be redirected to my-account page.
i tried to edit yith-wcwl-ajax.php file :
`// Add product in the wishlist
elseif( $_GET[‘action’] == ‘add_to_wishlist’ ) {
if(is_user_logged_in()){
$return = $yith_wcwl->add();if( $return == ‘true’ )
{ echo $return . ‘##’ . __( ‘Product added!’, ‘yit’ ); }
elseif( $return == ‘exists’ )
{ echo $return . ‘##’ . __( ‘Product already in the wishlist.’, ‘yit’ ); }
elseif( count( $yith_wcwl->errors ) > 0 )
{ echo $yith_wcwl->get_errors(); }wp_redirect( get_permalink( intval( $_GET[‘add_to_wishlist’] ) ) );
die();}
else{ wp_safe_redirect(get_site_url().”/my-account”); }
}`but its not working am i doing something wrong or other file needs to be modified?
Please help.Thanks
- The topic ‘redirect to login page if user is not logged in’ is closed to new replies.