• Resolved vishkey

    (@vishkey)


    I want to detect when a new user register in my web by the pluggin Nextend Facebook Connect. For that, I made a new extension, but it don’t shows in the event list. I need to do something more?

    <?php
    /**
     * Extension for nextend facebook conect
    
     * This file extends Achievements to support actions from Nextend facebook conect.
     *
     * @package Achievements
     * @subpackage ExtensionNextendFacebookConnect
     */
    
    // Exit if accessed directly
    if ( ! defined( 'ABSPATH' ) ) exit;
    
    /**
     * Extends Achievements to support actions from WordPress (core).
     *
     * @since Achievements (3.0)
     */
    function dpa_init_nextend_facebook_connect_extension() {
    	achievements()->extensions->nextend_facebook_connect = new DPA_Nextend_Facebook_Connect_Extension;
    
    	// Tell the world that the WordPress extension is ready
    	do_action( 'dpa_init_nextend_facebook_connect_extension' );
    }
    add_action( 'dpa_ready', 'dpa_init_nextend_facebook_connect_extension' );
    
    /**
     * Extension to add WordPress support to Achievements
     *
     * @since Achievements (3.0)
     */
    class DPA_Nextend_Facebook_Connect_Extension extends DPA_Extension {
    	/**
    	 * Constructor
    	 *
    	 * Sets up extension properties. See class phpdoc for details.
    	 *
    	 * @since Achievements (3.0)
    	 */
    	public function __construct() {
    		$this->actions = array(
    			'nextend_fb_user_registered'     => __( 'A new user register by Facebook.', 'dpa' ),
    			'nextend_fb_user_logged_in'      => __( 'A user logins by Facebook.', 'dpa' ),
    			'nextend_fb_user_account_linked' => __( 'A user links his Facebook account.', 'dpa' )
    		);
    
    		$this->contributors = array(
    			array(
    				'name'         => 'Vishkey',
    				'gravatar_url' => 'https://www.gravatar.com/avatar/24e481cf69e3db980e2aa83a086a5a4a.png',
    				'profile_url'  => 'https://profiles.www.ads-software.com/vishkey'
    			)
    		);
    
    		$this->description     = __( 'Provides events to Achiviemets with Nextend Facebook Connect.', 'dpa' );
    		$this->id              = 'NextendFacebookConnect';
    		$this->image_url       = trailingslashit( achievements()->includes_url ) . 'admin/images/nextend.png';
    		$this->name            = __( 'Nextend Facebook Connect', 'dpa' );
    		$this->rss_url         = 'https://www.ads-software.com/news/feed/';
    		$this->small_image_url = trailingslashit( achievements()->includes_url ) . 'admin/images/nextend-small.png';
    		$this->version         = 3;
    		$this->wporg_url       = 'https://www.ads-software.com/plugins/nextend-facebook-connect/';
    
    		add_filter( 'dpa_handle_event_user_id', array( $this, 'event_user_id'), 10, 3 );
    	}
    
    	/**
    	 * For the comment_post and post publish events, swap the logged in user's ID
    	 * for the post's author's ID. This is to support post moderation and publishing
    	 * by other users.
    	 *
    	 * @param int $user_id
    	 * @param string $action_name
    	 * @param array $action_func_args The action's arguments from func_get_args().
    	 * @return int|false New user ID or false to skip any further processing
    	 * @since Achievements (3.0)
    	 */
    	public function event_user_id( $user_id, $action_name, $action_func_args ) {
    		// Only deal with events added by this extension.
    		if ( ! in_array( $action_name, array('nextend_fb_user_registered') ) )
    			return $user_id;
    
    		// New user registration
    		if ( 'nextend_fb_user_registered' === $action_name ) {
    			return $action_func_args[0];
    		}
    	}
    }

    https://www.ads-software.com/plugins/achievements/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter vishkey

    (@vishkey)

    Ok, I made that works (only need to add the require in the achievements.php file).

    But now, the only action that works is the nextend_fb_user_linked. The other two, dont trigger of any way. I try with all filters, modify the do_action call in the nextend plugin file, everything, those other two actions simply don’t work.

    Plugin Author Paul Wong-Gibbs

    (@djpaul)

    I mean to get back to you soon, but I think it’s probably some well-intended caching in the options table that’s causing the problem.

    You shouldn’t need to edit a core plugin file to include your custom extension. I think if you drop this new file (aka plugin) in the /wp-content/mu-plugins/ folder, it will just work.

    Thread Starter vishkey

    (@vishkey)

    What file I need to put in the /wp-content/mu-plugins/ folder? The nextendfacebookconnect.php extension for your pluggin or the original Nextend Facebook Connect pluggin for wordpress?

    Plugin Author Paul Wong-Gibbs

    (@djpaul)

    > The nextendfacebookconnect.php extension for your pluggin

    Probably just this. I still intend to get back to you this weekend with advice for dealing with this issue. I haven’t forgotten.

    Thread Starter vishkey

    (@vishkey)

    Nope, didn’t work either…T.T
    I already lost a lot of time with this. If you solve o have any clue what is failing, please, let me know.
    I’m really thankful of your help, but I need to move forward. I’ll let this achievement for more later.

    Plugin Author Paul Wong-Gibbs

    (@djpaul)

    Take a look through https://www.ads-software.com/support/topic/actions-not-showing-in-choice-drop-down?replies=5 for someone else who has the same problem and explains what is going on.

    Thread Starter vishkey

    (@vishkey)

    That has nothing to do with my problem, but it tried anyway but how I expected don’t solve my problem.

    The 3 actions are in the dropdown menu without problem, but Achievements only reconizes one of them (An user links his facebook account).

    Plugin Author Paul Wong-Gibbs

    (@djpaul)

    Ok. Have you created a test plugin on your site where you hook debug code into those actions? Have you confirmed that those actions are actually firing when you expect them to?

    Thread Starter vishkey

    (@vishkey)

    Mmm, what I can confirm is that the sequence of code executes the “do_action” sentences in the Nextend Facebook plugin, tested with a javascript alert before and after those sentences. I don’t test the “do_action” function itself, but is a core function so if it fails, no one achievement must work, but it isn’t the scenario. So I think the problem is in the Achievement Plugin [but for my custom extension, not necesary for your core code :)]

    Thread Starter vishkey

    (@vishkey)

    I think the problem is: How do I tell to Achivements “hey, I wrote a new extension, please, load it”?
    Actually I modify the achivements.php and add a “require” line with the route, because no exists documentation for this step.
    It must be done in a distint way?

    Thread Starter vishkey

    (@vishkey)

    Ok, in the folder mu-plugins, I put the file test.php with:

    <?php
    function test () {
    echo ‘<script>alert(“otro test”)</script>’;
    }
    add_action(‘nextend_fb_user_logged_in’, ‘test’, 10, 0);

    The alert fires without problem, so confirmed that the problem is in achievements.

    Plugin Author Paul Wong-Gibbs

    (@djpaul)

    think the problem is: How do I tell to Achivements “hey, I wrote a new extension, please, load it”?

    You said you’ve edited achievements.php; that’s one way. ?? I’d suggest putting it inside plugins or mu-plugins as its own plugin. That way, you have a custom plugin and just turn it on/off easily.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘New extension don't work’ is closed to new replies.