So your template for actors will include a relationship form to connect existing contacts, which can be inserted directly in the template for actors.
Regarding the part about adding new contacts and having the form redirect back to the actor and to automatically connect them, you
- create a form to publish contacts
- you include a generic field for the actorid (you could use that as the field slug) where the default value is going to come from a URL parameter which, for the purposes of illustration I'm describing as actorid, for which you can use the shortcode
[wpv-search-term param='actorid']
Save the form, and insert it on some page.
Go back to your template for actors to add the link to this form, to which you will append the actor id using the actorid parameter.
You need to manually construct the link, like so:
<a href="[wpv-post-url item='154']?actorid=[wpv-post-id]">Add new contact</a>
Note that 154 is the ID of the page where I have the form to publish contacts inserted. If you use the GUI to insert the wpv-post-url shortcode you can search for the name of the post, or just look it up and add it manually.
So, when viewing the actor you'll see the "Add new contact" link to the page with the form that adds an actorid URL parameter. The form includes a generic field that grabs that actorid parameter value, so that it can then be used in some code triggered by the cred_success_redirect hook, e.g.
function ts_custom_redirect( $url, $post_id, $form_data ){
// Edit as required
$relationship = 'actor-contact';
$param = 'actorid';
$formid = 152;
if ( $form_data['id'] == $formid && isset( $_POST[$param] ) ){
$url = get_permalink( $_POST[$param] );
toolset_connect_posts( $relationship, $_POST[$param], $post_id );
}
return $url;
}
add_filter( 'cred_success_redirect', 'ts_custom_redirect', 10, 3 );
This does two things. One is to connect the new contact to the actor. The second is to update the redirect url so that it goes back to the same actor post. (Note, for this to work your form must include a redirect of some kind, which this code will overwrite.)