How to check if a term exists with rules - Drupal 7

1.7k Views Asked by At

I had a previous question combining two questions on this subject...but I think I explained a little bit vague...too much story...so I will ask just one question at a time :)

I would like to know how I can check if a taxonomy term exists with Rules in Drupal 7. I think I will need to do it with a custom PHP rule together with a native Drupal function (something like check_if_term_exists() ?).

But I cannot seem to find a correct way to do it.

1

There are 1 best solutions below

1
On

Nice and easy:

$tid = 5; // The term ID, you can't load by term name as such because multiple terms may have the same name within different (and even within the same) vocabularies.
$term = taxonomy_term_load($tid);

if ($term) {
  // The term exists
}
else {
  // The term doesn't exist
}