himanshuS
Support threads created in the last 30 days: 1
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
WPV Shortcodes do not work for post status other than published
Started by: himanshuS in: Toolset Professional Support |
1 | 2 | 3 years, 11 months ago | ||
Unable to transfer parent taxonomy data to child post using reference post
1
2
Started by: himanshuS in: Toolset Professional Support |
3 | 18 | 3 years, 11 months ago | ||
Unable to hide post edit link from non-authors using shortcode
Started by: himanshuS
in: Toolset Professional Support
Problem: I want to hide the edit post link from non authors along with other data. Solution: You can try wpv-conditional shortcode like this: Relevant Documentation: |
2 | 10 | 3 years, 11 months ago | ||
How to hide post when "post content" element is populated with Edit post form
Started by: himanshuS in: Toolset Professional Support |
2 | 11 | 3 years, 11 months ago | ||
Can not use Access control
Started by: himanshuS in: Toolset Professional Support |
2 | 4 | 3 years, 11 months ago | ||
Show only child taxonomy terms in the dropdown
Started by: himanshuS in: Toolset Professional Support |
2 | 5 | 3 years, 11 months ago | ||
Error On Custom Post Types in User Profile Edit Form
Started by: himanshuS in: Toolset Professional Support |
1 | 2 | 3 years, 11 months ago | ||
No data in parent field in child form
Started by: himanshuS in: Toolset Professional Support |
2 | 9 | 3 years, 11 months ago | ||
Likert Scale in Toolset Forms?
Started by: himanshuS in: Toolset Professional Support |
2 | 6 | 3 years, 11 months ago | ||
How to pre-select more than one M2M parent on a child post submission form?
Started by: himanshuS
in: Toolset Professional Support
Problem: I have two custom post types in a many-to-many (M2M) relationship. In a Form that creates new child posts, I would like to allow Users to select multiple parent posts and create those relationships automatically. Solution: Usually M2M relationships are managed in Relationship Forms after both parent and child posts are already created. To create M2M relationships between posts in a new child post Form, you must use a generic multiselect field and custom code. Here is the general approach: 1. Create a View of one of the parent post types. Click "Loop Wizard" above the Loop Editor and select the "list with separators" display type. In the next screen of the popup, click "Add a field" and add the post title, then click "Finish". In the loop editor, replace the code inside the wpv-loop tags with the following code: <wpv-loop> [wpv-item index=1] {"value":"[wpv-post-id]","label":"[wpv-post-title]"} [wpv-item index=other] ,{"value":"[wpv-post-id]","label":"[wpv-post-title]"} </wpv-loop> Be sure the checkbox "Disable the wrapping DIV around the View" is checked, and delete all the content from inside the wpv-no-items-found shortcode, like so: [wpv-no-items-found][/wpv-no-items-found] This View will be used to generate JSON-like options for each parent post in one generic multiselect field in Forms. You will repeat this process to create Views of any additional parent post types. Note the slug of this View for step 2 below. 2. Edit the child post Form using Expert Mode in the Form Builder. Click "Add generic fields" above the code editor and choose a multiselect generic field. In the popup, choose the option to "Get options from a shortcode". Insert a View shortcode that includes your parent post type View slug in the name attribute, like so: [wpv-view name="your-parent-post-type-view-slug"] Save the field, and the expert builder will insert a new shortcode for you automatically in the Form contents. It will look like this: [cred_generic_field type='multiselect' field='your-multiselect-field-slug'] { "required":0, "options":[ [wpv-view name="your-parent-post-type-view-slug"] ] } [/cred_generic_field] 3. Test the Form on the front-end of the site. You should see a multiselect field appear at this point with options for each parent post. 4. If the multiselect field is displaying correctly, now you need to add some PHP code using the cred_save_data hook that will capture the selected values from that multiselect field and loop over those values when the Form is submitted successfully. Inside this loop over the selected values, you will call the toolset_connect_posts API to create relationships between each selected option and the new child post. You can add this code in a child theme's functions.php file, or in a new custom code snippet in Toolset > Settings > Custom Code tab. Here is an example of such a cred_save_data hook: add_action('cred_save_data', 'tssupp_associate_multiple_related_posts',10,2); function tssupp_associate_multiple_related_posts($post_id, $form_data) { $forms = array( 123 ); $relationship_1_slug = "parent-child-relationship-slug"; $ms_field_slug = "your-multiselect-field-slug"; if ( in_array( $form_data['id'], $forms ) ) // test if the form being submitted is in the list of form IDs we want to target { $ms_selections = $_POST[$ms_field_slug]; // the $_POST superglobal contains an array of the selected parent post IDs foreach($ms_selections as $ms_selection) { toolset_connect_posts( $relationship_1_slug, $ms_selection, $post_id); // while looping over selected parents, connect them to the new child post programmatically } } } In this example, you would replace 123 with the numeric ID of the child post Form, or a comma-separated list of child post Form IDs if there is more than one new child post Form. You would replace parent-child-relationship-slug with the slug of the relationship between the parent post type and the child post type. You would replace your-multiselect-field-slug with the slug of the generic multiselect field you created in the Form builder. Inside the "if" condition, you can create new foreach loops for each parent post type, but let's hold off on that for now and just get one parent type saving correctly. Relevant Documentation: |
2 | 8 | 3 years, 11 months ago | ||
How to use relationship fields?
Started by: himanshuS in: Toolset Professional Support |
2 | 4 | 3 years, 11 months ago | ||
Unable to load parent post taxonomy using recommended shortcode
Started by: himanshuS in: Toolset Professional Support |
2 | 4 | 3 years, 11 months ago | ||
How to create child post link when using elementor template
Started by: himanshuS in: Toolset Professional Support |
2 | 5 | 3 years, 11 months ago |