Add default wishlist images for newly created wishlists

This article only applies to the pro version of the plugin.

When a wishlist owner creates his wishlist, he has to set a foreground image and a background image for the wishlist if he chooses, as shown in the picture below:

Sometimes instead, the store administrator may want to set default images for the wishlist owners based on their user profile pictures or other something else, so that the wishlist owners don’t have to bother setting the pictures themselves, except if they want to change them.

This is very easy to do as shown by the code below.

/**
 * Set a default images for the wishlist when the wishlist is created
 * In this case, 7 is the id of the foreground image we want to set, and
 * 21 is the id of the background image.
 * These ids can vary based on the user.
 */
function my_nmgr_set_default_wishlist_image_ids( $data, $object ) {
	if ( is_a( $object, 'NMGR_Wishlist' ) && !$object->get_id() ) {
		/**
		 * You can access the current user here using wp_get_current_user()
		 * and extract information about him that you can use to set his wishlist images.
		 */
		$data[ 'thumbnail_id' ] = 7;
		$data[ 'background_image_id' ] = 21;
	}
	return $data;
}