Jump to content

How to get followers and following members


Go to solution Solved by ReyDev,

Recommended Posts

Posted (edited)

Query the core_follow table. I don’t remember if there’s any method ready for this and can’t check now as I’m on a mobile device. 

EDIT: you can probably try: $member-> followers().

Edited by Adriano Faria
Posted
46 minutes ago, Adriano Faria said:

you can probably try: $member-> followers().

thanks a lot , works for followers. what about the following, i also want to fetch the members who follow a specific member. I took a look at `\IPS\Member` class and found this method. 

public function following( $app, $area, $id )
	{
		//
	}

I have no idea if it works for the following members or not.

Posted
	/**
	 * Following
	 *
	 * @param	string	$app	Application key
	 * @param	string	$area	Area
	 * @param	int		$id		Item ID
	 * @return	bool
	 */

this method just returns a bool value. checks if a member follow the current member or not. I didn't find other method that returns the following members list!!

  • Solution
Posted (edited)
14 minutes ago, Adriano Faria said:

Then make a query!

I did!
 

for followers :

\IPS\Db::i()->select( 'follow_member_id', 'core_follow', [ 'follow_app=? AND follow_area=? AND follow_rel_id=?', 'core', 'member', \IPS\Member::loggedIn()->member_id ] )


for following :

\IPS\Db::i()->select( 'follow_rel_id', 'core_follow', [ 'follow_app=? AND follow_area=? AND follow_member_id=?', 'core', 'member', \IPS\Member::loggedIn()->member_id ] )


 maybe helps someone!

Edited by ReyDev
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...