Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide dialog on certain pages #56

Open
naloo opened this issue Sep 26, 2016 · 6 comments
Open

hide dialog on certain pages #56

naloo opened this issue Sep 26, 2016 · 6 comments

Comments

@naloo
Copy link

naloo commented Sep 26, 2016

hello, thanks for this great plugin, one question, i need to hide the dialog on cerain pages, i saw the function here: https://github.com/JayWood/content-warning-v3/wiki/Dev-Documentation#hide-the-dialog-on-certain-pages-regardless-of-cookies

do i place this in my functions.php ?
where do i set the page-ids?

and cookies are not expiring, no matter what is set, but i have seen, that people have already reported this.

thanks for your help! nadia

@JayWood
Copy link
Owner

JayWood commented Sep 27, 2016

@naloo The $post_ob is the post object, it's an instance of WP_Post which you can see here it's properties https://codex.wordpress.org/Class_Reference/WP_Post

This would go in your functions file yes, and this is the page ID - 1 == $post_obj->ID.

The cookies should expire, not sure why they're not but I may have to re-visit jQuery Cookie to see what's going on. Unless you're referring to #52 that is.

@naloo
Copy link
Author

naloo commented Sep 27, 2016

hi jay, there is something wrong with the code you provided, like this it works:

function maybe_show_dialog( $bool = true, $post_ob = null ) {
$examplePost = get_post();

if ( $examplePost->ID == 10 OR 
    $examplePost->ID == 12  {
    return false;
}

return $bool;

}
add_filter( 'cwv3_should_gate', 'maybe_show_dialog', 10, 2 );

@naloo
Copy link
Author

naloo commented Sep 27, 2016

sorry, round bracket missing, this is the correct code:

`function maybe_show_dialog( $bool = true, $post_ob = null ) {

$examplePost = get_post();

if ( $examplePost->ID == 10 OR 
    $examplePost->ID == 12) {
    return false;
}

return $bool;

}
add_filter( 'cwv3_should_gate', 'maybe_show_dialog', 10, 2 );`

@JayWood
Copy link
Owner

JayWood commented Sep 28, 2016

@naloo you don't need to get_post() that's what $post_ob is

@vintagepornbay
Copy link

both of them not working for me.

@vintagepornbay
Copy link

`/**

  • Maybe Show Dialog
  • @param bool $bool Default true
  • @param WP_Post $post_ob A WP_Post object
  • @return bool True to show the dialog, false to hide it.
    */
    function maybe_show_dialog( $bool = true, $post_ob = null ) {
    $examplePost = get_post();

if ( $examplePost->ID == 164) {
return false;
}

return $bool;

if ( is_user_logged_in() ) {
    return false;
}

return $bool;

}
add_filter( 'cwv3_should_gate', 'maybe_show_dialog', 10, 2 );`

okay this worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants