Hi, Thanks for the reply.
Link of my CRED form:
hidden link
I tried the solution i found here:
https://toolset.com/forums/topic/restrict-user-to-select-one-category-only/
1. I have divided the individual categories (Taxonomie= “Stellen”) into two parent categories: “Aktiv” and “Nicht Aktiv”
2. I created a view of my taxonomy. In the Query Filter section, I filtered by the main taxonomy "Active".
3. I added the following code to my theme's functions.php file (I replaced "12345" with the numeric id “1730” of the newly created view):
add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 10, 3);
function prefix_clean_view_output( $out, $id ) {
if ( $id == '1730' ) { //Please adjust to your Views ID
$start = strpos( $out, '<!-- wpv-loop-start -->' );
if (
$start !== false
&& strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
) {
$start = $start + strlen( '<!-- wpv-loop-start -->' );
$out = substr( $out , $start );
$end = strrpos( $out, '<!-- wpv-loop-end -->' );
$out = substr( $out, 0, $end );
} else {
$start = strpos( $out, '>' );
if ( $start !== false) {
$out = substr( $out, $start + 1 );
$end = strpos( $out, '<' );
$out = trim(substr( $out, 0, $end ));
}
}
}
return $out;
}
4. I deleted all the code in the View "1730"´s loop output editor. And pasted the following:
[wpv-layout-start][wpv-items-found]<!-- wpv-loop-start --><wpv-loop>[wpv-item index=1]{"value":"[wpv-taxonomy-slug]","label":"[wpv-taxonomy-title]"}[wpv-item index=other],{"value":"[wpv-taxonomy-slug]","label":"[wpv-taxonomy-title]"}</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-no-items-found][wpml-string context="wpv-views"]No items found[/wpml-string][/wpv-no-items-found][wpv-layout-end]
5. I have inserted in my CRED form editor a generic "Select" field. I gave the field a name (aktiv-stelle) (Label: “Offene Stellen *”) and where it says "Use a shortcode instead of options" I pasted in the shortcode to display the view I've been working on:
[wpv-view name="view-aktiv-stellen"]
6. In the front end of the CRED form the field "Offene Stellen *" appears with only the sub-categories of the parent category "Aktiv". (The field "Offene Stellen *" appears when in the field "Initiativ-Bewerbung*" there is the choice "Nein")
Perfect!!!
There's just one big problem:
When I choose a subcategory and submit the CRED Form the subcategory does not appear in the backend: the category field is empty.
where did I go wrong? What should I do to make the choice made in the frontend CRED module appear in the backend as well?
Thank you very much for helping.
Francesco