Okay it sounds like a lot you need to accomplish here. I can give you some examples to get started. I suggest you work on the first form to get started, and I suggest you start with a Create User Form. Why? Because if the first Form Creates a User profile, then you can use that User's ID as the post author of any other posts that are created during that first form submission. Otherwise, you may need to update the post author for each post later. So first, create a New User Form. That form will include all kinds of fields automatically for setting the new User's login, password, email, any custom User fields, and so on. You'll also add in generic fields to capture information about the Member post you want to create, the Organization post if you want to create one, or the selected Organization if your User chooses an existing one.
To create a generic field that contains all the existing Organizations as options, create a View of Organizations using the legacy View editor. Run the Loop Wizard and choose the "list with separators" loop style. In the last screen of the wizard popup, insert the post title and click finish to create the loop automatically. Then replace the contents of the wpv-loop tags as shown here:
<wpv-loop>
[wpv-item index=1]
{"value":"1","label":"Create an Organization"},{"value":"[wpv-post-id]","label":"[wpv-post-title]"}
[wpv-item index=other]
,{"value":"[wpv-post-id]","label":"[wpv-post-title]"}
</wpv-loop>
You can now insert this View as the options for a generic select field in your Form. I would switch to expert mode. Generic select fields populated by Views have this general syntax in the expert builder:
[cred_generic_field field="generic-organization-select" type="select" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":1,
"default":"",
"options":[ [wpv-view name="your-organizations-view-slug"] ]
}
[/cred_generic_field]
Once you have your Form populated with all the necessary generic fields, you'll start working on the PHP code that captures those generic field values and uses them to create new posts and add post relationship associations. Use the cred_save_data API for this purpose. This code can go in your child theme's functions.php file, or in a new snippet set to run everywhere and activated in Toolset > Settings > Custom Code. Here's a template you can use to get started:
// one form to create user, member, and possibly organization
// https://toolset.com/forums/topic/create-edit-form-which-combines-user-fields-and-several-custom-post-fields/
add_action('cred_save_data', 'create_user_automation',10,2);
function create_user_automation($user_id, $form_data)
{
// if a specific form
if ($form_data['id']==123)
{
// get a generic field value from the $_POST superglobal under the slug key
$selected_organization = $_POST['generic-organization-select'];
$member_title = $_POST['generic-member-title'];
$member_field_one = $_POST['generic-member-field-one'];
// ...add additional field values here as needed
// insert the new member post
$member_args = array(
'post_title' => $member_title,
'post_type' => 'member',
'post_status' => 'publish',
'post_author' => $user_id
);
$member_id = wp_insert_post($member_args);
// set a custom field in the new member post
// remember that Types fields use a slug prefix of wpcf- in the database
update_post_meta($member_id, 'wpcf-member-field-one-slug', $member_field_one);
if($selected_organization==1){
// in this case, the User did not select an existing organization
// so you probably need to create one like you just created member with wp_insert_post
// then connect it with toolset_connect_posts like the example in the else block below
// your code to insert the organization post should go here
} else {
// in this case the User selected an existing organization
// connect new member and selected organization in the post relationship with slug 'member-org-rel-slug'
// adjust that slug if needed
toolset_connect_posts( 'member-org-rel-slug', $member_id, $selected_organization );
}
}
}
Replace 123 with the numeric ID of the Create User Form, and replace the various field and relationship slugs throughout the code as needed. You can see several examples in the code, including how to access the value of a generic field, how to create a post, how to add a custom field to a post after you create it programmatically, how to test the value of a generic field and set up a conditional based on that value, and how to connect two posts in a post relationship programmatically.
Documentation for the major PHP APIs used in this code:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
https://developer.wordpress.org/reference/functions/wp_insert_post/
https://developer.wordpress.org/reference/functions/update_post_meta/
I think this gives you enough to get started on setting up that first Create User Form, including generic fields, maybe including a select field for existing Organizations, and then setting up your cred_save_data hook for the first Form.
Once that's working as expected, I think the next step is to create an edit User form and add all the same generic fields. The trick will be how to show all the correct information in those fields, and I think you'll need a custom shortcode for that. I'm getting ahead though, let's get form 1 and snippet 1 working correctly before moving on to editing.