Hi there, we are creating a CRED form to make it easier for our authors to add content to our site from the front-end. We want to build two content template designs that can each be used for our posts. We then want our authors to choose via dropdown or radio button on the form either a 'complex post' or 'simple post'. Depending on which option they choose, the post will display with a different layout. How do we add a content template choice in our CRED form?
//Show a specific Content Template applied to a given post for not logged in visitors and in every place where this post appears:
add_filter( 'wpv_filter_force_template', 'prefix_fixed_content_for_visitors', 99, 3 );
function prefix_fixed_content_for_visitors( $template_selected, $id, $kind ) {
if ( !is_user_logged_in() && $id == 345 ) { // if the user is not logged in and is trying to view the post with ID 345
$template_selected = 123; // assign a fixed Content Template with ID 123 that contains a static text
}
return $template_selected;
}
You should adjust the the above filter code as per your requirement by checking which user selected which content template to display.
Hi there, I think maybe I wasn't clear enough on what I was trying to do. I have 2 content templates made for posts. I haven't assigned them to the 'post' post type because I want that to be chosen on the form when our author creates the article. So for example, I tried this with general CRED radio buttons, but it didn't quite work:
As you can see I've added attribute "persist":1 to above CRED generic field shortcode, this attribute will help you to save the Generic field value to database.