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.

I use the CubePoints plugin that rewards users with 1000 points via the following function:

if( function_exists(‘cp_alterPoints’) && is_user_logged_in() ){
    cp_alterPoints(cp_currentUser(), 1000);
}

Now, I would like to reward a user 1000 points for viewing one specific custom page that I created with with a page template.
Lets call it landingpage.php and the post ID of this page is 24122.

Is there any way to accomplish this?
Something like "if is page landingpage" (or "if is post=24122"), then perform the above function.

share|improve this question
add comment

1 Answer 1

Have a look at the is_page() conditional tag and at conditional tags in general.

is_page() takes both post IDs as well as slugs (and more) as arguments, hence you can choose how you'd like to identify the page in question.

With the above given ID, this, for instance, ought to work:

if( function_exists('cp_alterPoints') && is_page(24122) ){
    cp_alterPoints(cp_currentUser(), 1000);
}
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.