0

I’ve been searching for solution to my problem but posts already made are not fulfilling the answer to me, or I'm just not qualified enough to work this out. Here is what I need:

I’ve got a simple landing page with a form. What I need is a way to create unique url’s for people I choose so only they can access this site and fill out the form. URL has to be active only for 7 days and once used, deactivated immediately. The unique URL’s should work a long, which means at the same time I can generate multiple URL’s.

The other way to approach this problem is to generate many passwords that I can send to people I choose. Same story – every password is unique and works only once. Page is password restricted and when user puts the password in it’s no longer active.

The best possible addition to this would be - deactivating / expiring the URL / visitor access the moment they send the form <- but that's not necessary.

I’m really not type of guy who just wants solution given to him on a silver platter, but right now… I have my back against the wall and literally no time. Any help is appreciated. Thank you.

0

Is the page something they pay to gain access to? Why is the accessing it one time so important? Can they access it as many times as they want, but only for a day? (I know this is a comment but I do not have enough reputation to comment so can a moderator please move this over to a comment? thanks.)

  • The idea behind it is that we are picking winners randomly from event. In order to receive your gift as a winner you need to fill out the form on a page with the adress etc. As a winner you receive a link to that form and you can use it only once - one reward. – estedog Jun 5 '19 at 3:35
0

You could add a setting using add_option( 'access_keys', [ 'key_1', 'key_2 ] ) to check against when loading the page.

add_action( 'init', 'wpse339612_check_access_codes' );
function wpse339612_check_access_codes(){

    if( isset( $_GET['key'] ) ){

        $available_keys = get_option( 'access_keys' );

        $key_index = array_search( filter_var( $_GET['key'], $available_keys );

        if( $key_index !== false ){

             /*User has access! Delete the key from the available keys*/
             unset( $available_keys[$key_index] );
             update_option( 'access_keys', $available_keys );

        }

    }

}

Then whenever a user hits a URL of https://yoursite.com?key=key_1 they will get to the access condition and the key will be deleted from the database.

  • Where should I add that function as well ass add_option setting? I'm sorry but I'm an absolute amateur as for coding. Usually I was using CodeSnippet but if I add it this way, is there a possibility that someone would get access to all of the codes? – estedog Jun 5 '19 at 3:47

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.