0

We provide access to several databases from within the our library, but outside our library users need to go through a verification step. As such we have a different link for some IPs (eg on our network/not on our network).

Using PHP we are able to serve the appropriate link, but as far as I know WP doesn't have a native way to serve different links depending on the users' IP. However we have several links in the CMS portion of our website which is powered by WP. Is there a way in WP to serve different links based on IP?

1
  • Note that it will be impossible to do full page caches if you do this as the first person who loads the page will be cached and all follow up loads will have that persons unique URL
    – Tom J Nowell
    Nov 3, 2016 at 14:39

1 Answer 1

1

Yes, use a shortcode:

function aslums_first_shortcode( $atts, $content ) {
    if ( IS INSIDE NETWORK? CHECK ) {
        return 'inside the network'.$content;
    }
    return 'outside the network'.$content;
}
add_shortcode( 'aslums_shortcode', 'aslums_first_shortcode' );

In your post content:

You are: [aslums_shortcode]

As an aside, could a user outside your network bypass verification if they knew what the URL users inside the network are using? You may want to reconsider how authentication works on your network

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.