Gravity Forms Multi Page Losing POST value - gravity-forms-plugin

I have a complex Gravity Form built, it has 10 pages. I am using fields to build a "string" that I then match to a CPT name to get meta data from to display a selection, based on user choices in the form.
One field I have is not holding its value in POST. I can see it when I select the value on the page, then when I click to next page the value is still there. However, after two pages the value ( and field ) disappear from POST.
This is the function I have put together that builds my product string.
add_filter( 'gform_pre_render_12', 'display_choice_result' );
function display_choice_result( $form ) {
$current_page = GFFormDisplay::get_current_page( $form['id'] );
$html_content = "";
$prod_string = "";
if ( $current_page >= 10 ) {
foreach ( $form['fields'] as &$field ) {
// Check for a class of "product-builder-item" on the field
// I use this as another way to denote what fields to add to string
if ( strpos( $field->cssClass, 'product-builder-item' ) === false ) {
continue;
}
//gather form data to save into html field (Field ID 14 on Form ID 12)
//exclude page break and any hidden fields
if ( $field->id != 14 && $field->type != 'page' ) {
$is_hidden = RGFormsModel::is_field_hidden( $form, $field, array() );
$populated = rgpost( 'input_' . $field->id );
// Make sure the field we are getting the value from is not hidden and has a value
if ( !$is_hidden && $populated !='' ) {
$html_content .= '<li>' . $field->label . ': ' . rgpost( 'input_' . $field->id ) . '</li>';
$prod_string .= rgpost( 'input_' . $field->id );
}
}
}
// Do a bunch of stuff here with the $prod_string variable
// ...
// ...
// ...
}
return $form;
}
Screenshots showing the POST disappearing..The POST field in question is input_22 with a value of 18000
This is one page after I choose from the field
This is two pages after,
Anyone run into this before or have any idea why it would be disappearing?
Thank you.

I was having the same exact issue as you described. I realized that a jQuery function was interfering with Gravity Form process. The jQuery function was set to change a zip code field from type text to tel so the number pad would open up on mobile devices. This is what was causing my issue.

Related

How to Add ACF Date & Time field to Woocommerce Emails line items

I have a Date & Time as an ACF field for my products which are events, I need to add the date into the emails that get sent out. Below is as far as I've got, it will display the word Date, but the ACF field doesn't display. I'm sure it's something really obvious but I can't see it :(.
Any help would be really appreciated.
// Add ACF Date & Time to New Order Email
add_action('woocommerce_order_item_meta_end', 'email_confirmation_display_order_items', 10, 4);
function email_confirmation_display_order_items($item_id, $item, $order, $plain_text) {
echo '<div>Date: '. wc_get_order_item_meta( $item_id, 'event_date_and_time') .'</div>';
}
This is how I did it in the end...
// Add ACF Info to New Order Email
add_action('woocommerce_order_item_meta_end', 'email_confirmation_display_order_items', 10, 4);
function email_confirmation_display_order_items($item_id, $item, $order, $plain_text) {
$product = $item->get_product();
if ( empty( $product ) ) {
return false;
}
$date = get_field( 'event_date_and_time', $product->get_id() );
if ( !empty( $date ) ) {
echo '<div style="font-size:10px;">Date: '. $date .'</div>';
}
}

Is it possible to hide form from non-registered users?

I need to hide form with some shortcode [contact-form-7 id="3080"] from non-registered users in WordPress.
So i've tried to use inserted tags like this '[client][contact-form-7 id="3080"][/client]' and it doesn't work.
with this php code
function access_check_shortcode( $attr, $content = null ) {
extract( shortcode_atts( array( 'capability' => 'read' ), $attr ) );
if ( current_user_can( $capability ) && !is_null( $content ) && !is_feed() )
return $content;
return '';
}
add_shortcode( 'access', 'access_check_shortcode' );
This one isn't interesting, cause i need to show it inside the template
<?php
if ( is_user_logged_in() )
echo do_shortcode( '[contact-form-7 id="1234" title="Contact form 1"]' );
?>
Are you willing/able to install third party plugins? If so, you might want to check out either or both of these:
Hide This (https://wordpress.org/plugins/hide-this/)
Eyes Only (https://bs.wordpress.org/plugins/eyes-only-user-access-shortcode/)
Both of these work by enabling shortcode that can be wrapped around specific content. I believe both have options to how only to logged-in users.

how to set a value for Zend_Form_Element_Submit (zendframework 1)

I have am having trouble setting the basic values of a zend form element submit button (Zendframework1). I basically want to set a unique id number in it and then retrieve this number once the button has been submitted.
Below is my code. you will nots that I tried to use the setValue() method but this did not work.
$new = new Zend_Form_Element_Submit('new');
$new
->setDecorators($this->_buttonDecorators)
->setValue($tieredPrice->sample_id)
->setLabel('New');
$this->addElement($new);
I would also appreciate any advice on what I use to receive the values. i.e what method I will call to retrieve the values?
The label is used as the value on submit buttons, and this is what is submitted. There isn't a way to have another value submitted as part of the button as well - you'd either need to change the submit name or value (= label).
What you probably want to do instead is add a hidden field to the form and give that your numeric value instead.
It's a little bit tricky but not impossible :
You need to implement your own view helper and use it with your element.
At first, you must add a custom view helper path :
How to add a view helper directory (zend framework)
Implement your helper :
class View_Helper_CustomSubmit extends Zend_View_Helper_FormSubmit
{
public function customSubmit($name, $value = null, $attribs = null)
{
if( array_key_exists( 'value', $attribs ) ) {
$value = $attribs['value'];
unset( $attribs['value'] );
}
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable, id
// check if disabled
$disabled = '';
if ($disable) {
$disabled = ' disabled="disabled"';
}
if ($id) {
$id = ' id="' . $this->view->escape($id) . '"';
}
// XHTML or HTML end tag?
$endTag = ' />';
if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
$endTag= '>';
}
// Render the button.
$xhtml = '<input type="submit"'
. ' name="' . $this->view->escape($name) . '"'
. $id
. ' value="' . $this->view->escape( $value ) . '"'
. $disabled
. $this->_htmlAttribs($attribs)
. $endTag;
return $xhtml;
}
}
So, you assign the helper to the element :
$submit = $form->createElement( 'submit', 'submitElementName' );
$submit->setAttrib( 'value', 'my value' );
$submit->helper = 'customSubmit';
$form->addELement( $submit );
This way, you can retrieve the value of the submitted form :
$form->getValue( 'submitElementName' );

Access Form values in my Symfony executeAction backend

So one of my pages consists of a quiz form that has several questions of type multiple choice, the choices are specified as radio buttons. I have been scanning the Symfony documentation to find out how to access form field values inputted by the user. Thing is, this isn;t a doctrine or propel based form, and neither do I require the values to be stored in the database, hence executing a $form->save() makes little sense to me. But I do require access to specific values of my form in my backend once the user hits submit.
Most of Symfony documentation that i have run into doesn't necessarily explain how this can be done. I would assume it would be something to the effect of :
$request->getParameter( 'radio_choices_id selected value ').
Thanks to all who read this and Cheers to the ones who respond to it :)
Parijat
Hm, it is very simple if I understand your question right)
For widget:
$this->widgetSchema['name'] = new sfWidgetFormChoice(array('choices' => array('ch_1', 'ch_2')));
Ok,in action:
$this->form = new FaqContactForm();
if ($request->isMethod('post')) {
$this->form->bind($request->getParameter($this->form->getName()));
if ($this->form->isValid()) {
$your_val=$this->form->getValue('name');
//or
$your_val=$this->form['name']->getValue());
}
}
In backend in protected function processForm(sfWebRequest $request, sfForm $form)
you have
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid())
{
$notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
try {
$product = $form->save();
} catch (Doctrine_Validator_Exception $e) {
$errorStack = $form->getObject()->getErrorStack();
$message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
foreach ($errorStack as $field => $errors) {
$message .= "$field (" . implode(", ", $errors) . "), ";
}
$message = trim($message, ', ');
$this->getUser()->setFlash('error', $message);
return sfView::SUCCESS;
}
Before $product = $form->save(); try
$your_val=$form->getValue('name');
//or
$your_val=$form['name']->getValue());

Contact Form 7 - Mass Checkboxes displayed by line break separation within notification emails

I have a question about the checkbox value items that I receive in my mail after someone fills in my contact form 7.
If someone has checked these three boxes in the form:
CHECKBOX1
CHECKBOX2
CHECKBOX3
Then in my mail they appear as:
CHECKBOX1, CHECKBOX2, CHECKBOX3
However, I would like to change the comma separation into line breaks.
Plus add a unique value for each checkbox so I can add in a URL:
Should be displayed in the email like this:
CHECKBOX1 – URL LINK
CHECKBOX2 – URL LINK
CHECKBOX3 – URL LINK
I really need this, can somebody please tell me where I can change this within contact form 7’s code?
Or does someone know another way without using contact form 7?
For HTML emails,
Edit: wp-content/plugins/contact-form-7/includes/classes.php
Look for function mail_callback. In my version it's at line 631.
Edit the function to be as so:
function mail_callback( $matches, $html = false ) {
if ( isset( $this->posted_data[$matches[1]] ) ) {
$submitted = $this->posted_data[$matches[1]];
if ( $html ) {
$replaced = strip_tags( $replaced );
$replaced = wptexturize( $replaced );
}
if ( is_array( $submitted ) )
$replaced = join( '<br/>', $submitted );
else
$replaced = $submitted;
$replaced = apply_filters( 'wpcf7_mail_tag_replaced', $replaced, $submitted );
return stripslashes( $replaced );
}
if ( $special = apply_filters( 'wpcf7_special_mail_tags', '', $matches[1] ) )
return $special;
return $matches[0];
}