Title: Multisite
Last modified: August 24, 2016

---

# Multisite

 *  Resolved [drh192](https://wordpress.org/support/users/drh192/)
 * (@drh192)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multisite-259/)
 * Hi,
 * I wanted to use this on multisite for logged in users only. Made the following
   changes
 *     ```
       /app/entities/user/userrepository.php
   
       public function getFavorites($user_id = null)
       	{
       		$saveType = $this->settings_repo->saveType();
   
       		if ( is_user_logged_in() ) {
       			$user_id = ( isset($user_id) ) ? $user_id : get_current_user_id();
       			$key = (is_multisite() ? 'simplefavorites_' . get_current_blog_id() : 'simplefavorites');
       			$favorites = get_user_meta($user_id, $key);
   
       			if ( empty($favorites) ) return array();
       			return $favorites[0];
       		}
       		$favorites = ( $saveType == 'cookie' ) ? $this->getCookieFavorites() : $this->getSessionFavorites();
       		return $favorites;
       	}
       ```
   
 * And
 *     ```
       app/entities/favorite/syncuserfavorite.php
   
       	public function updateUserMeta($favorites)
       	{
       		if ( !is_user_logged_in() ) return false;
       		$key = (is_multisite() ? 'simplefavorites_' . get_current_blog_id() : 'simplefavorites');
       		return update_user_meta( get_current_user_id(), $key, $this->array_flatten($favorites) );
   
       	}
       ```
   
 * By adding a site_id $key to the user meta I have the functionality I want, could
   you support this in a future release?
 * [https://wordpress.org/plugins/favorites/](https://wordpress.org/plugins/favorites/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Kyle Phillips](https://wordpress.org/support/users/kylephillips/)
 * (@kylephillips)
 * [11 years ago](https://wordpress.org/support/topic/multisite-259/#post-5972180)
 * Thanks for the suggestion. I’m currently updating the plugin to be multisite 
   compatible. It’ll be implemented a bit different than the method you’ve used (
   in order to provide more flexibility in the plugin API). So… once it’s released
   please be aware that in your case, updating will cause favorite counts to essentially
   be reset.
 * Since your user meta will be saved in separate rows, I’m sure you could combine
   the counts fairly quickly and resave.
 *  Plugin Author [Kyle Phillips](https://wordpress.org/support/users/kylephillips/)
 * (@kylephillips)
 * [11 years ago](https://wordpress.org/support/topic/multisite-259/#post-5972182)
 * As of v1.1.0 (just released), Favorites is multisite compatible. Additional (
   optional) parameters have been added to the template functions and shortcodes.
 *  [RightBeatRadio](https://wordpress.org/support/users/rightbeatradio/)
 * (@rightbeatradio)
 * [11 years ago](https://wordpress.org/support/topic/multisite-259/#post-5972183)
 * Hi Kyle, I noticed you mentioned favorite counts being reset in drh192’s case.
 * Will this affect our website as well or only in this case?
 * Thanks
 *  Plugin Author [Kyle Phillips](https://wordpress.org/support/users/kylephillips/)
 * (@kylephillips)
 * [11 years ago](https://wordpress.org/support/topic/multisite-259/#post-5972186)
 * Favorite counts (number of times a post has been favorited) shouldn’t be effected
   at all (not even in drh192’s case above).
 * The code above alters the way logged-in users’ favorites are saved. Favorite “
   counts” are saved as post meta for the associated post.
 *  [RightBeatRadio](https://wordpress.org/support/users/rightbeatradio/)
 * (@rightbeatradio)
 * [11 years ago](https://wordpress.org/support/topic/multisite-259/#post-5972187)
 * Cool thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Multisite’ is closed to new replies.

 * ![](https://ps.w.org/favorites/assets/icon-128x128.png?rev=1677726)
 * [Favorites](https://wordpress.org/plugins/favorites/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/favorites/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/favorites/)
 * [Active Topics](https://wordpress.org/support/plugin/favorites/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/favorites/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/favorites/reviews/)

## Tags

 * [multisite](https://wordpress.org/support/topic-tag/multisite/)

 * 5 replies
 * 3 participants
 * Last reply from: [RightBeatRadio](https://wordpress.org/support/users/rightbeatradio/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/multisite-259/#post-5972187)
 * Status: resolved