Skip to content
Gaurav TiwariDocs

How to Show Different Links to Members and Visitors

Updated October 19, 2026

A “Start the course” button means different things to different people. A paying member wants the first lesson, and a visitor who hasn’t bought yet should see the sales page. Two buttons on every page confuse both of them.

To show different links to members and visitors, you keep one branded link and let it check who’s clicking. Logged-in members with the right WordPress role go to one destination, and everyone else goes to the link’s normal destination.

GT Link Manager doesn’t switch destinations by role on its own. It does run every redirect through a filter called gtlm_redirect_url, and WordPress already knows who’s logged in at that point. A short must-use plugin joins the two.

The role-to-URL map lives in each link’s Notes field, so you change destinations from wp-admin, not from code.

Before You Start

  • Members with a WordPress role. WordPress roles are the slugs such as subscriber or customer. Membership plugins often add their own role, and you’ll need its slug.
  • File access to your site, to add a file to wp-content/mu-plugins.
  • A branded link, with the visitor destination, such as your sales page, as its Destination URL.

To find a role’s slug, open Users → All Users, filter by the role and look at the role= part of the address bar.

  1. Go to GT Links → All Links and click Edit on the link.
  2. Keep Destination URL as the page for visitors.
  3. Set Redirect Type to 302, because the destination now depends on who clicks.
  4. In Notes, add one line per role, in the format shown below.
  5. Click Save Link.
role:subscriber = https://yoursite.com/course/lesson-1/
role:administrator = https://yoursite.com/wp-admin/

Any other text in Notes stays untouched. The code only reads lines that start with role:.

Add the Role Filter

  1. Create the folder wp-content/mu-plugins if it doesn’t exist.
  2. Create a file in it named gtlm-roles.php.
  3. Paste the code below and save.
<?php
/**
 * Plugin Name: GT Link Manager Role Links
 * Description: Sends logged-in users to a role-specific URL from the link's Notes.
 */

defined( 'ABSPATH' ) || exit;

function gtlm_role_urls( array $link ): array {
	$urls = array();
	foreach ( explode( "\n", (string) ( $link['notes'] ?? '' ) ) as $line ) {
		if ( preg_match( '/^\s*role:([a-z0-9_-]+)\s*=\s*(\S+)\s*$/i', $line, $m ) ) {
			$urls[ strtolower( $m[1] ) ] = esc_url_raw( $m[2] );
		}
	}
	return $urls;
}

add_filter( 'gtlm_redirect_url', function ( $url, $link ) {
	if ( ! is_user_logged_in() ) {
		return $url;
	}
	$urls = gtlm_role_urls( $link );
	foreach ( wp_get_current_user()->roles as $role ) {
		if ( ! empty( $urls[ $role ] ) ) {
			return $urls[ $role ];
		}
	}
	return $url;
}, 10, 2 );

// Never send a permanent redirect for a link that depends on who clicks.
add_filter( 'gtlm_redirect_code', function ( $status, $link ) {
	return gtlm_role_urls( $link ) ? 302 : $status;
}, 10, 2 );

The second filter is a safety net. If someone sets a role-mapped link back to 301 later, the code still sends a 302, so no browser remembers the visitor’s destination after they log in.

A user with several roles gets the first role WordPress lists for them that has a line in Notes. Logged-out visitors and users whose roles aren’t listed get the normal Destination URL.

Why Caching Isn’t a Problem Here

GT Link Manager sends no-cache headers with every redirect, and most page caches skip logged-in users anyway. So a member’s redirect doesn’t get served to a visitor, or the other way round.

The one setup to check is an edge cache, such as a Cloudflare cache rule, that caches everything regardless of headers. Exclude your link prefix, such as /go/*, from that rule.

Check It Works

You need 2 browsers, or one normal window and one private window:

  1. In the private window, logged out, click the branded link. You should land on the visitor destination.
  2. In the normal window, log in as a user with a mapped role, then click the same link. You should land on that role’s URL.
  3. Log in as a user whose role isn’t in Notes. They should get the visitor destination.

Run curl -I on the link from a terminal. You’re logged out there, so the Location header shows the visitor destination with a 302 status.

When the Wrong Page Opens

SymptomLikely causeFix
Members still get the sales pageThe role slug in Notes doesn’t matchCheck the slug under Users → All Users
Everyone gets the member pageThe member URL sits in Destination URLPut the visitor page there and the member page in a role: line
Members get the old page after a changeThe browser kept an older 301The filter now sends 302, so clear that browser’s cache once
UTM tags disappear for membersThis filter replaces the whole URLRun the UTM filter at priority 20, as the UTM guide does
Members get a 404The role: URL is not a full https:// addressUse a full URL in Notes

What It Won’t Do

  • It doesn’t check purchases or subscriptions directly. It checks WordPress roles. If your membership plugin tracks access some other way, swap the role check for that plugin’s own access function.
  • It doesn’t protect the member page. Anyone with the URL can still visit it, so keep your membership plugin’s access rules on that page.
  • It doesn’t work for logged-out members. A member who isn’t logged in counts as a visitor until they log in.

The Role-Based Redirects in GT Link Manager reference uses the same Notes format. To keep campaign tags on these links as well, see How to Keep UTM Tags Through a Redirect.

Share

Was this helpful?

Still stuck? Open a support ticket