0

am researching with google but didn't find answer to how-to do it. I am just WP beginner with writing own functions

My client : has a WordPress page where future customers fills out data and submit to db. Client creates specific offer for that customer. He wants display the offer publicly except the personal data which would be password protected.

clienstdomain.com/offers displays a WP page with 'some content'

clientsdomain.com/offers/ha28dTFeHByXXJy7e58aa7f698470eUENk9XS5tj/yWTVKNqUPc

shoudl display the WP with 'some content' + unique offer data for client

ha28dTFeHByXXJy7e58aa7f698470eUENk9XS5tj/yWTVKNqUPc is the unique id of the offer

I confused where to start as how to create such a unique id and how to embed it into WP. Was thinking about

writing :add to submit with some randomizer a token

reading: check current url

<?php $current_url="//".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>

finding the string in URL from the last backslash and read if is in the length of token and if I can find in db then add data with jQuery

Am I on right path?

1 Answer 1

0

If I understand your problem, this procedure should work for you:

  • create a custom post type nameofplugin_offer

  • use a form to get the offers from customers, save them as the above CPT (see wp_insert_post())

  • in your CPT archive template ( that would be archive-nameofplugin_offer.php, see Template Hierarchy), within the loop, list all the public details of the offers, then add this code before the end of the loop:

    if( is_user_logged_in() ):
    
      ?> <a href="<?php the_permalink() ?>">Offer details</a> <?php
    
    endif;
    
  • in your CPT template ( single-nameofplugin_offer.php) display all the public details of the offer, then wrap the private information in this function - is_user_logged_in() - similar with the code above.

Following the links you should be able to implement this procedure in your code. If you need more help for any of the above steps, let me know in a comment and I'll expand on that point.

Your Answer

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

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