Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

New Edit

I would like to show the_content BEFORE the more tag when the cookie is not set and the_content AFTER the more tag when the cookie is set.


I could not answer to my own question because my reputation is less than 10 so I will edit instead.

This is the final answer. This will show the_content before the more tag if the cookie is NOT set, and the_content AFTER the more tag once the cookie IS set. Very useful when creating Lead Gen landing pages or when you want to display some content before or after a certain action is taken.

Thanks.

<?php global $more;
while (have_posts()) : the_post();
if(isset($_COOKIE['CookieName'])) {
$more = 1;
the_content('',TRUE,''); } 
else {
$more = 0;
the_content(); } ?>
share|improve this question
    
I think this is more of a jQuery/cookies/session question, rather than a WordPress-specific question. Can you please clarify the WordPress-specific nature of this question? –  Chip Bennett Nov 11 '12 at 17:06
    
@ChipBennett Not sure about the close vote. Maybe this could be solved otherwise with WP. –  kaiser Nov 11 '12 at 19:10
2  
@kaiser as-written, the question isn't WP-specific. It's an if/then conditional based on a cookie. I'd be happy to recant a close vote if the question were edited to make it WP-specific. –  Chip Bennett Nov 11 '12 at 19:20
add comment

1 Answer

Try using the jQuery Cookie plugin

You can set a cookie to start with that could be called InfoSubmitted with value of 'No' and when they submit their info it changes to 'Yes'

To set the cookie first make sure jQuery and the Cookie plugin are installed and then use this:

jQuery.cookie('InfoSubmitted', 'No');

Once the user submits the form then change the cookie to Yes:

jQuery.cookie('InfoSubmitted', 'Yes');

Once you have that working then you would need to check what value the cookie has.

if (jQuery.cookie('InfoSubmitted') == "No") {
    //do not show information

} else {
    //show information
}

This is all using jQuery and Javascript. You could possibly use PHP to read the cookies set by the plugin and use them in your PHP code

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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