Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'gform_field_input', 'gform_cart_subsection', 10, 5 );
- add_action( 'gform_pre_submission', 'pre_submission_handler' );
- add_filter( 'gform_entry_field_value', 'category_names', 10, 4 );
- // gform_cart_subsection() targets a field with CSS class "subsection" and rewrites it with a number of
- // input fields: one input per post ID stored in the $favs array.
- function gform_cart_subsection($input, $field, $value, $lead_id, $form_id) {
- if( $field["cssClass"] == "subsection" ) {
- $favs = wpfp_get_users_favorites(); // This gives an array of post ID's
- $input = "<br />";
- foreach ( $favs as $fav ){
- $input .= '<label for="fav' . $fav . '">' . get_the_title($fav) . '</label><input name="field_4[]" id="fav' . $fav . '" type="text" value="Add note..."><br/>';
- }
- }
- return $input;
- }
- function pre_submission_handler($form){
- $_POST["input_4"] = json_encode($_POST["input_4"]);
- }
- function category_names($value, $field, $lead, $form){
- if( $field['id'] == 4 ) {
- $newvalue = '';
- $choices = json_decode($value, true);
- foreach($choices as $choice) {
- $new_value .= '<li>'.$choice.'</li>';
- }
- return '<ul>' . $new_value . '</ul>';
- } else {
- return $value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement