WordPress.org

Forums

Achievements for WordPress
[resolved] multiple event names? (2 posts)

  1. Stephanie Leary
    Member
    Posted 1 year ago #

    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[0]->post_type )
    	return $event_name;
    
    $postid = $func_args[0]->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.

    http://wordpress.org/plugins/achievements/

  2. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 1 year ago #

    Hi Stephanie,

    I don't mean for this to sound abrupt, but no; it needs to be a string. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Achievements for WordPress
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.