Created
May 4, 2015 11:33
-
-
Save thomasgriffin/c4e9e0d2f8254f6c4cf9 to your computer and use it in GitHub Desktop.
Exclude optin if on a certain category.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'optin_monster_api_output', 'tgm_om_filter_lightbox_by_category', 10, 4 ); | |
function tgm_om_filter_lightbox_by_category( $optins, $optin, $fields, $post_id ) { | |
// If in a particular category, remove the lightbox. | |
$cat_exc = 362; // Replace with the category ID to target. | |
$slug = 'sjdfhsjakdkg'; // Replace with the unique slug for the lightbox you want to remove. | |
$categories = wp_get_object_terms( $post_id, 'category', array( 'fields' => 'ids' ) ); | |
foreach ( (array) $categories as $category_id ) { | |
if ( $category_id && $category_id == $cat_exc && in_array( $slug, $optins ) ) { | |
unset( $optins[ $slug ] ); | |
break; | |
} | |
} | |
// Return the modified output. | |
return $optins; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment