[Resolved] multiple event names?
I’m working on a site that has per-category achievements. This has been tricky to set up. Right now, I’m manually creating new actions for each category in addition to the first action, which occurs any time someone posts to this CPT:
$this->actions = array( 'lettermo_new_letter' => __( 'The user sends a letter', 'dpa' ), 'lettermo_new_package' => __( 'The user sends a package', 'dpa' ), 'lettermo_new_intl' => __( 'The user sends international mail', 'dpa' ), );
… and then mapping them to event names like so:
if ( 'letter' !== $func_args->post_type ) return $event_name; $postid = $func_args->ID; // Switch the event names for Letters if ( has_term( 'package', 'extras', $postid ) ) return 'lettermo_new_package'; if ( has_term( 'international', 'extras', $postid ) ) return 'lettermo_new_intl'; return 'lettermo_new_letter';
(Full code here: https://gist.github.com/sillybean/8718584)
That is, if the post has a term from the ‘extras’ taxonomy, return that event name; otherwise use the default.
This works as long as I have only one term selected per post. I’m going to be in trouble as soon as someone tries to mix them — e.g. sending an international package.
Is there a way to return multiple event names? I tried an array and it didn’t appear to work.
- The topic ‘[Resolved] multiple event names?’ is closed to new replies.