Custom fields in Permalinks?

  1. Use add_rewrite_tag( $tag, $regex ); to register a rewrite tag for the custom field.
  2. Filter post_type_link to replace the rewrite tag. The second argument is the post object, so you have always access to the post ID.

For a sample implementation see my plugin T5 Rewrite. It does exactly that in the class T5_Rewrite_Tag_Custom.