0

I would like to request some help about an addon I really need to add to my website:

I need when user have my special link for exmaple: "website.com/?secret=yes" or "website.com/post/?secret=yes" they will see my regular website but with the secret content to show my secret content I need to add if variable (secret=yes) then add to site few javascript scripts in head section and add DIV Container in body section. This content is sensitive to premium users so It's must be impossible to find this with view source for regular users. And I use Wordpress site if it helps :)

Your help makes my website much better so thank you!

1 Answer 1

4

On the WordPress templates you'd like to show the secret content you could do something like this:

<?php 
  $secret = isset( $_GET[ 'secret' ] ) ? sanitize_text_field( $_GET['secret'] ) : false; 
if( 'yes' === $secret ) : ?>
    <div>
        <p>My secret content</p>
    </div>
<?php endif; ?>

Your users can access the secret content of the post/page that uses the template with this code in it by appending the query variable secret=yes.

http://your-website.com/the-greatest-post-ever/?secret=yes

I hope this helps. :)

Sign up to request clarification or add additional context in comments.

6 Comments

Thank you so much it looks exactly as what I need, What will be the best way to use it? Add it right where I wanted the secret content and create another one like this for Javascripts scripts and add them lets say in header.php? Or there is a better option? :)
And another important thing the regular users will not be able to find this i hope?
Not unless they have the secret key, which in this case is 'yes'. There are definitely more secure ways to do this.
What can you recommend that is more secure than this? But still should show if I have a special link? And what about the first question do I use it right? :)
I got a question how to hide in URL the variable ?secret=yes after they have arrived to the page?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.