最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

permalinks - Unique one time use URL

programmeradmin4浏览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.

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.

Share Improve this question asked Jun 4, 2019 at 21:31 estedogestedog 11 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 2

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?key=key_1 they will get to the access condition and the key will be deleted from the database.

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.)

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论