larsH-3
Support threads created in the last 30 days: 0
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
Automatically assign a parent post and custom field value in a CRED form that creates child posts
Started by: larsH-3
in: Toolset Professional Support
Problem: I have a CRED form that creates child posts. I would like to have the parent post be automatically assigned as the current post where the CRED form is displayed. I would also like a custom field value to be automatically the current User's name. Solution: You can use the wpv-user shortcode and the value attribute to predefine the user's name: [cred_field field="your-field-slug" post="your-post-type-slug" value="[wpv-user field='user_firstname'] [wpv-user field='user_lastname']"] The urlparam value will pass in a URL parameter value to any field: [cred_field field='_wpcf_belongs_parentslug_id' urlparam='wpvpostparent' select_text='--- not set ---' class='form-control' output='bootstrap'] Then you can link to your CRED form page using the wpvpostparent URL parameter to specify a parent post ID: If you want to use the current post ID as the value of the parent field, you can use the wpv-post-id shortcode and the $current_page operator: [cred_field field='_wpcf_belongs_parentslug_id' value='[wpv-post-id id='$current_page']' select_text='--- not set ---' class='form-control' output='bootstrap'] Pro tip: if you want to hide the predefined parent select field you can wrap it in a hidden div: <div style="display:none;"> [cred_field field='_wpcf_belongs_parentslug_id' value='[wpv-post-id id='$current_page']' select_text='--- not set ---' class='form-control' output='bootstrap'] </div> Relevant Documentation: |
2 | 3 | 7 years, 1 month ago |