You could use forward hooks as described in this post and register the desired layers using their name.
name