I want to protect a page under developpement. The problem is that people are sharing that link. I’d like to manually give a custom link to the users, store the IP they use and then prevent the link being reused on a different IP. I’m using wordpress, and It’s the entire site i’d like to protect. Also, is there a way to track who shared the URL?
Exemple :
I’d give a friend this http://exemple.com/abc, that link works as long as the user is on the IP that was first used. If that user shares that link to someone else or another IP tries to access the site using the URL I’d like to log it somehow.
I’ll give you some basic advises, since this is relatively complicated and I don’t have the time to write all of the code 🙂 .
First you need to add a plain admin page – on this page initially you want to have a
<form>
with a text field and a submit field. The text field will be where you enter the page URL that you want to share.You will also have an option stored in the database(we will create that later). It should be an array, to which you will later add the URL’s.
Once you submit the URL you will create a nonce for this URL – it must be unique for it(you can use
uniqid()
for instance). You will then store the URL in an array like this:Then you just need to add a function that will check if a user is allowed to view a specific URL, like so(add the code to your
functions.php
):You’ll have to figure-out the rest on your own, but I gave you most of the stuff, so if you look around a bit, you’ll be able to accomplish that.
PP: I haven’t tested the code, but in theory it should work – tell me if some part of it doesn’t work.