Support » Plugin: Achievements for WordPress » Adding more actions

  • Resolved Peter Hudson



    I have got my wordpress plugin actions working with achievements (yay!) and I managed to add some extra actions to my wordpress plugin to make it work the way I wanted it to.

    The problem is, I decided that I wanted to add some more actions to my wordpress plugin and then to achievements. I added my new actions to the array of actions in my achievements extensions (extending the list) but:

    They do not show in the selectable actions in the add achievement screen (pick event).

    When I look up my wordpress plugin in the achievements plugin screen it shows that the action I added is available, but obviously it is not registering the action.

    I’m thinking its something to with the way that a plugin is initially added to achievements but I’m not sure how to get it to recognise my action.

    The actions I originally had work as intended and trigger achievements so its really a question of why the extra actions are not being recognised.

    Thanks if you can help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Paul Gibbs


    BuddyPress Lead Developer

    Can you share your code, so I can see it?

    Can you also look in your database and see if your new actions were added to the wp_term_taxonomy and wp_term_relationships tables?

    Hi Paul,

    Maybe its something I’m doing wrong I guess.

    I’ve posted the code here… hopefully it looks okay when I post because I’ve never posted any before. The code is to support the Love It Pro plugin by Pippin (hope he doesn’t mind..).

     * Extension for Love It Pro Extension
     * This file extends Achievements to support actions from Love It
     * @package Achievements
     * @subpackage ExtensionLoveIt
    // Exit if accessed directly
    if ( ! defined( 'ABSPATH' ) ) exit;
     * Extends Achievements to support actions from Love It.
     * @since Achievements (3.0)
    function dpa_init_loveit_extension() {
    	achievements()->extensions->love_it_pro = new DPA_Love_It_Extension;
    	// Tell the world that the Love It extension is ready
    	do_action( 'dpa_init_loveit_extension' );
    add_action( 'dpa_ready', 'dpa_init_loveit_extension' );
     * Extension to add Love It support to Achievements
     * @since Achievements (3.0)
    class DPA_Love_It_Extension extends DPA_Extension {
    	 * Constructor
    	 * Sets up extension properties. See class phpdoc for details.
    	 * @since Achievements (3.0)
    	public function __construct() {
    		$this->actions = array(
    			'like_process_ach'		 => __( 'A user likes a story.', 'dpa' ),
    			'like_for_author'		 => __( 'Author has story liked.', 'dpa' ),
    		$this->contributors = array(
    				'name'         => 'Pippin',
    				//'gravatar_url' => '',
    				'profile_url'  => '',
    		$this->description     = __( "Allows users to like posts.", 'dpa' );
    		$this->id              = 'love-it-pro';
    		$this->image_url       = trailingslashit( achievements()->includes_url ) . 'admin/images/loveit.jpg';
    		$this->name            = __( 'Love It', 'dpa' );
    		$this->rss_url         = '';
    		$this->small_image_url = trailingslashit( achievements()->includes_url ) . 'admin/images/loveit.jpg';
    		$this->version         = 1;
    		$this->wporg_url       = '';

    Then in my themes functions files I put:

    //add support for love it pro to achivements
    function love_it_ach_init() {
    require 'Achievements-love-it/love-it-ach.php';
    add_action( 'dpa_init', 'love_it_ach_init' );

    the require specifies the folder and file for my extension.

    It is not showing the second action in my Database – so in:

    wp_terms ….. I see term_id: (199) name:like_process_ach etc

    wp_term_taxonomy …… I see term_taxonomy_id: (217) term_id: (199) taxonomy: dpa_event description: A user likes a story

    I see all the other terms/taxonomies added by the original extensions also, but not the second in my code.

    wp_term_relationship …… I see the relationship between the above term taxonomy and the post that I created (object_id: 3674 (my post id) and term_taxonomy_id: 217

    It’s quite possible I’ve been stupid here as this is my first proper attempt.

    Plugin Author Paul Gibbs


    BuddyPress Lead Developer

    I think you’ve just run into a quirk of how I treat extensions at the moment. A few people have got in contact.

    When you add an extension with a new/unique “ID”, Achievements will go through all its supported actions and add them to the taxonomy tables etc (basically, it’ll set them up). This will occur on the very first page load after you set up a new extension.

    Any changes after this initial “install” need to be handled manually. You’ve two solutions:

    1) Quick fix: Change the extension’s ID to something new.


    2) Proper fix: An option is set in the wp_options table called “_dpa_extension_versions”, which is a serialised array of each extension and its version. De-serialise this, remove your extension/version, re-serialise it and store.

    Both of these will cause the extension to be “re-installed”.

    Thanks for getting back Paul, I actually figured that might be the case. It makes the most sense really when thinking about how extensions might be added.

    The ability to add extensions in this way is such a massive bonus and has been so well thought out by yourself, then a little ‘quirk’ like that is a small price to pay.

    Just an update, deserialised in the Database and all is working fine now – actions have been updated and are available.

    Very happy!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding more actions’ is closed to new replies.