Problem: I have a new User CRED form that allows guests to register. When they submit the form, I would like to automatically create a custom post that includes information from the form, and I would like to restrict access to that post to the created member only.
Solution: 1. Create a Custom Post Entry for "Band Name" on Member Registration.
This can be accomplished with a bit of custom code using the cred_save_data API.
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
if ($form_data['id']==1234)
{
$my_post = array(
'post_title' => $_POST['some_custom_input'],
'post_status' => 'publish',
'post_author' => $post_id,
'post_type' => 'band-post-type-slug'
);
// Insert the post into the database
wp_insert_post( $my_post );
}
}
1234 should be changed to match the numeric ID of your User CRED form, and 'some_custom_input' should be changed to match the name of an input containing the data you would like to use in the Band post title. The data in the $my_post array can be modified according to the wp_insert_post documentation.
2. Only allow the registered Member edit his own Band Page.
In the code I provided above, I have configured the new post's author to be automatically set to the User that was just created during registration. Once this registration form is up and running, you should be able to use Access post and form restrictions based on the post Author (Member can edit own vs Member can edit any).
Problem:
How to associate parent post ID when you create child posts using CRED form.
Solution:
You can add CRED generic hidden field to hold the parent ID of child post and build custom shortcode that return the desired parent id in this case.
Problem: I would like to set up Properties (a CPT) so that they can be associated with Amenities. What is the best way to do this so the Amenities can be reused across multiple Properties?
Solution: Use a custom field on your Properties custom post type that allows your users to select multiple Amenities using checkboxes. The same checkboxes will be available on all Property posts, so you can reuse the same options but make different selections. Use unique numeric values for each option, and save "0" when nothing is checked.
To display the selected Amenities on a Property post on the front-end, use conditionals to determine whether an option was checked: