How to disable redirect functions when editing pages & shortcode questiojn

Hello. I have am trying to setup a fairly simple website that accepts two roles of users, friends and family, and presents each with a different link depending on their role. First I am having some trouble redirecting logged in users off of the login page and users that need to log in onto the login page.

I added the following to functions.php and it seems to work a little too well:

`function redirect_from_login_page() {`

`if( is_page( ‘login’ ) && is_user_logged_in() ) {`

`wp_redirect( ‘welcome’ );`

`exit;`

`}`

`}`

`add_action( ‘template_redirect’, ‘redirect_from_login_page’ );`

​

`function redirect_to_login_page() {`

`if( !is_page( ‘login’ ) && !is_user_logged_in() ) {`

`wp_redirect( ‘login’ );`

`exit;`

`}`

`}`

If I navigate the website with this code in it works. However, if I go to edit the login page it freezes and when I comment out this code it works fine. I suspect I am getting redirected because I am logged in. This must not be the right way to go about this, and suggestions would be great.

​

Second thing I am getting hung up on is the shortcode for displaying a different link depending on how you are logged in. As a test I used editor but I also tried the custom family and friends roles I created. Everything just shows up as text instead of what is in-between the text:

https://preview.redd.it/ozgh2fvcmxob1.png?width=285&format=png&auto=webp&s=5278010ecc2ccbc6038cf59a6f3d8e107936dae0

https://preview.redd.it/9hjvuuhlmxob1.png?width=612&format=png&auto=webp&s=dd0f4b8d37b5484c43181aee87bdd6a095066b5d

This may not be the right way to go about it either. Here I am using a widget called shortcode. Ideally I’d like to have the Sign Up button redirect to a different URL depending on the users roles so if that’s a possibility I could use a hand sorting how how to do so. Otherwise I can put the different urls in the shortcode.

Thanks!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer