Can variables be used to rewrite a Custom Post Type permalink? [duplicate]

filter “pre_post_link” to change the permalink rule, the first attribute is the rule set to the administrator and the second is the element which is to form the link

function my_pre_post_link( $permalink, $post, $leavename ) {
  // filtered by post_type, returns the format permalink
  if( $post->post_type != 'book' ) return '/bookis_custom/%postname%';
  return $permalink;
}

add_filter( 'pre_post_link', 'my_pre_post_link', 9, 3 );