• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

RESOLVED Update no longer works with Formidable Forms

Messages
5
Likes
0
Points
1
#1
Hi,

I applied the update on a couple of different sites of mine that are using formidable forms and the snippets no longer worked after applying the update. I had to revert to the previous version and when I did that, any snippets I had modified using the latest version were no longer accessible when I put the old version back in place.

I tested snippets without formidable forms hooks within them, and they seem to work fine. For some reason, it appears that it is only with formidable forms.

Sorry, forgot to mention that this happens when not using a shortcode.

Cheers,

Tom
 

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#2
Hi.

Send me the snippet code that stopped working after the update. And specify what parameters it has, "Insertion location" for example
 
Messages
5
Likes
0
Points
1
#3
Hi,

Thanks for getting back to me so quickly.

The snippet is a php snippet that is set to run everywhere. No parameters and no insert location.

Here is the code:

PHP:
add_filter('frm_pre_update_entry', 'modify_hike_entry_fields', 10, 2 );
add_filter('frm_pre_create_entry', 'modify_hike_entry_fields');
function modify_hike_entry_fields($values){
if ( $values['form_id'] == 9 ) { //change 5 to your form id
// Check and see if Hike Leaders Drop Down is enabled
        if (do_shortcode('[pre_populate_hike_leaders]') == 'Yes')
        {
            $hikeleaders = $_POST['item_meta'][210];
            //var_dump($hikeleaders);
            $hikeleadernames = '';
            $hikeleaderemails = '';
            if (is_array($hikeleaders))
            {
                foreach ( $hikeleaders as $huserid ) {
                    $user = get_user_by( 'id', $huserid );
                    $hikeleadernames = $hikeleadernames . $user->display_name . ', ';
                    $hikeleaderemails = $hikeleaderemails . $user->user_email . '; ';
                }
                $hikeleadernames = substr($hikeleadernames,0,strlen($hikeleadernames)-2);
                $hikeleaderemails = substr($hikeleaderemails,0,strlen($hikeleaderemails)-2);
            }
            else
            {
                $user = get_user_by( 'id', $hikeleaders );
                $hikeleadernames = $hikeleadernames . $user->display_name;
                $hikeleaderemails = $hikeleaderemails . $user->user_email;
            }
            $values['item_meta'][162] = $hikeleadernames;
            $values['item_meta'][163] = $hikeleaderemails;
            //var_dump($values['item_meta']);
        }
    }

    // Fix Distance if needed
    $distance = $_POST['item_meta'][101];
    if ($distance !="")
    {
        if (trim($distance) == "0")
        {
            $distance = "";
        }
        else
        {
            $pos = strpos(strtoupper(trim($distance)),"KM");
            if ($pos === false)
            {
                $distance = trim($distance) . " km";
            }
        }
        $values['item_meta'][101] = $distance;
    }
    return $values;
}
 
Last edited by a moderator:

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#4
We found a bug in our plugin. We will fix it in the next update, but you can fix it yourself now. Replace the lines in the file
wp-content\plugins\insert-php\includes\class.execute.snippet.php
from
35: add_action( 'wp', array( $this, 'executeEverywhereSnippets' ), 1 );
to
35: add_action( 'plugins_loaded', array( $this, 'executeEverywhereSnippets' ), 1 );

Let us know if this solved the problem.