• Greetings,

    I’m in the middle of creating a BP Follow hook for myCRED (the points management plugin) and I’m wondering how to get the dynamic values from the bp_follow_start_following action?

    My add_action call looks like this:
    add_action( 'bp_follow_start_following', array( $this, 'add_follow' ), 20, 1 );

    And the action that I’m adding looks like this:

    public function add_follow( $follow ) {
    			global $wpdb, $bp;		
    
    			$follower_id = $follow->follower_id;
    
    			$leader_id = $follow->leader_id;
                    }

    Am I going about this in the right way?

    Thanks

    https://www.ads-software.com/plugins/buddypress-followers/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author r-a-y

    (@r-a-y)

    That looks correct.

    I’m assuming you’re doing this within a class, which is why you’re using – array( $this, 'add_follow' ).

    This should be sufficient:

    add_action( 'bp_follow_start_following', array( $this, 'add_follow' ), 20 );
    
    public function add_follow( $follow ) {
    	$follower_id = $follow->follower_id;
    	$leader_id = $follow->leader_id;
    }

    I removed the globals in your class method. Only reference them if you need to use it. Add $wpdb back if you need to run queries and $bp if you need to reference anything inside the $bp global.

    Thread Starter Christian Freeman (codelion)

    (@takinglife2themax)

    Alright thanks.
    I’ve got it working now, and I’ll post a link to the finished code snippet when it’s complete.

    Thread Starter Christian Freeman (codelion)

    (@takinglife2themax)

    Ok, it’s done. If anyone needs to integrate BP Follow with MyCRED, you can use this code here to add a custom hook.

    Thanks again for the assist.

    Plugin Author r-a-y

    (@r-a-y)

    Thanks!

    I’ve added it to the wiki:
    https://github.com/r-a-y/buddypress-followers/wiki

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to Get leader_id and follower_id’ is closed to new replies.