Conditional Content

To add content that will only show up if a button is completed (and hides if it’s not), use:

[wpc_completed_content]Conditional content[/wpc_completed_content]

To add content that will only show up if a button is incomplete (and hides when it’s completed), use:

[wpc_incomplete_content]Conditional content[/wpc_incomplete_content]

For either of the above code, you can add a button name to it, so it’s conditional based on a specific button on the lesson, like so:

[wpc_completed_content name="button-one"]Conditional content[/wpc_completed_content]

You can also show the conditional text of another lesson by referencing “post” in either shortcode, like so (where 435 is the post id):

[wpc_completed_content post="435"]

You can create button-specific conditional content:
[wpc_completed_content name="buttonname"]I am a completed button![/wpc_completed_content]

You can combine button-specific and page specific conditional content::

[wpc_incomplete_content name="button-one" post="435"]Conditional content[/wpc_incomplete_content]

You can even do page-specific conditional content, for when all the buttons on a certain page are completed:
[wpc_if_page_completed] I am a completed page![/wpc_if_page_completed]

Or if they’re not:
[wpc_if_page_incomplete] I am not a completed page![/wpc_if_page_incomplete]

If you want to show conditional content for completed pages on a different page, add the “page” to the above shortcodes:

[wpc_if_page_completed page="123"] I am a completed page![/wpc_if_page_completed]

To show conditional content based on a fully completed specific course, use:
[wpc_completed_content course="Course Name"]I am a completed course![/wpc_completed_content]

Or for incomplete specific courses:
[wpc_incomplete_content course="Course Name"]I am not a completed course![/wpc_incomplete_content]

To show course-specific conditional content for the course you’re currently on:

[wpc_if_course_completed]I am a completed course![/wpc_if_course_completed]

And:
[wpc_if_course_incomplete]I am not a completed course![/wpc_if_course_incomplete]

New for 2.9+

[wpc_has_next_to_complete][/wpc_has_next_to_complete]

If you want to conditionally show some content if there is another lesson after your current one, you can use this conditional block.

[wpc_has_no_next_to_complete][/wpc_has_no_next_to_complete]

If you want to conditionally show some content if there is NO next lesson after your current one, you can use this conditional block. For example, if it’s the last lesson in a course.

[wpc_has_last_completed][/wpc_has_last_completed]

If you want to conditionally show some content if a user has completed a post.

[wpc_has_no_last_completed][/wpc_has_no_last_completed]

If you want to conditionally show some content if a user has not completed a post. For example, if a user has just started, they’ll have completed no last lesson.

[wpc_has_next_page][/wpc_has_next_page]
And [wpc_has_no_next_page][/wpc_has_no_next_page]
And [wpc_has_previous_page][/wpc_has_previous_page]
And [wpc_has_no_previous_page][/wpc_has_no_previous_page]

This can be used anywhere on a site, for example for your lessons dashboard. These four conditionals let you show custom messages if a user has more lessons to complete on pages, or if they have no lessons/pages to complete. This uses the same sort/order functionality that the [wpc_list_pages] shortcode users.

[wpc_if_button_completed][/wpc_if_button_completed] And [wpc_if_button_incomplete][/wpc_if_button_incomplete]

Conditionally shows a custom message or further shortcodes if the button on the page is completed.

You can also specific page ID or button name in the above shortcodes, like so:

[wpc_if_button_completed post="123" name="Button Name" async="true" hide="true"]Good work! Nothing to see here.[/wpc_if_button_completed]

Where async=”true” helps get around any caching you might have enabled and hide=”true” removes the conditional content from being commented out in the HTML (so code snoopers won’t see it).

[wpc_if_page_completed][/wpc_if_page_completed]
And [wpc_if_page_incomplete][/wpc_if_page_incomplete]

You can also specify post or page ID to use conditionals for one page on a separate page. By default, it uses the current page, unless you specify the ID, like this:

[wpc_if_page_completed post="123" async="true" hide="true"]Only visible if the page is completed.[/wpc_if_page_completed]

Conditionally shows a custom message or further shortcodes if all the buttons on a page (or post or custom content type) are completed.

[wpc_if_course_completed][/wpc_if_course_completed]
And [wpc_if_course_incomplete][/wpc_if_course_incomplete]

Conditionally shows a custom message or further shortcodes if all the buttons within a course are completed.

You can also supply the course name to this conditional, if you want to show a conditional for one course on the page or post of a different course. Otherwise, if you use this conditional, it’ll show based on the current course of the page or post.

[wpc_if_course_completed course="course name" async="true" hide="true"][/wpc_if_course_completed]

Using hide=”true” in conditionals

Normally, when completion conditionals are not met, WPComplete will still print the content out to the page’s HTML, but will hide it until the condition is met. When you use hide=”true”, but the condition isn’t met, WPComplete will not print the content out to the page’s HTML. This removes the conditional content from being hidden in the HTML (so code snoopers won’t see it).

This option works for the following conditionals:

Using async=”true” in conditionals

By adding async=”true” to a conditional, you can bypass any caching plugins you’ve got.

This option works for the following conditionals:

Next to complete

For next to complete, you can add json=”true” to return as JSON.

Also, you if want to add next to complete within a link, you can add link=”true” to output the URL, like so:

<a href="[wpc_next_to_complete link="true"]">Next!</a>

 

Return to support

Want 10% off the PRO version of WPComplete, just for hopping on our list?

No spam or BS, just product update emails.