top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to add variable inside an embedding gravity forms in Wordpress?

0 votes
463 views

I need to add a variable inside an array of an embedding gravity forms to populate 2 hidden fields: email and jobname.

Here is my code:

<?php 

    $email = get_field( "email_application" );
    $jobtitle = get_the_title();

    gravity_form( 5, false, false, false, array('email'=>'echo "$email";','jobname'=>'print "$jobtitle";'), false); 
?>

I know that echo, print or just the variable doesn't work as it show like this in my code:

<input name="input_6" id="input_5_6" type="hidden" value="print $jobtitle" class="gform_hidden" aria-invalid="false">

and

<input name="input_5" id="input_5_5" type="hidden" value="echo "$email";" class="gform_hidden" aria-invalid="false">

Instead I should get:

<input name="input_6" id="input_5_6" type="hidden" value="My job title" class="gform_hidden" aria-invalid="false">

and

<input name="input_5" id="input_5_5" type="hidden" value="myaddress@email.com" class="gform_hidden" aria-invalid="false">

Can someone could point me in the right direction.

Thank you.

posted Aug 3, 2017 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Since you are already using php in the code you showed you can just use variable names as shown in the code below:

gravity_form( 5, false, false, false, array('email'=>$email,'jobname'=>$jobtitle), false); 
answer Aug 21, 2017 by Sanam
Similar Questions
+2 votes

I have moderate level PHP programming skills. I am also interested in merging those skills inside of the WordPress app. With their advanced responsive design themes and many other functions it seems like a good idea. I have tried loading some PHP plug-ins in WP – but I don't seem to get them to do more than basics.

Can anybody help me on how I can get started working with PHP/MySQL inside of the WordPress app?

0 votes

I have Wordpress site and I have incorporated Disqus into my posts but I am not sure how to add them to my pages. Any help will appreciated?

0 votes

I building a website on Wordpress. When I add this below code

$(document).ready(function() {  
$('#readerareaimg img').each(function(){
var filename = $img.attr('src')
$img.attr('title', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));
$img.attr('alt', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));
});  

My website will generate alt and title tags automatically on images based on their file name, but I want to add any word or text before the file name. For example file name is phoneimg.jpg and it will display alt="phoneimg", but I want that alt to become alt="read phoneimg". How can I do this?

0 votes

I am developing a wordpress portal. I am sending html content(youtube iframe) with ajax from frontend pages. But while I am inserting that post wp_insert_post removes iframe codes in it. There is no problem with ajax or somewhere else. I guess there is somekind of filter. How can I disable that and insert iframe code?

Code before inserting -> $_POST["content"]

<div class="line nVideo" style="text-align: center;" ><iframe id="player" type="text/html" width="650px" height="380px" src="http://www.youtube.com/embed/mY8BZsIgg74?showinfo=1&amp;enablejsapi=1&amp;color=white&amp;origin=http://432designstudio.com" frameborder="0" allowfullscreen=""></iframe></div><div id="empty-line" class="nText " ><div>gasdgdsag</div>

And after insertation i call content again -> get_post_field('post_content', $postID)

<div class="line nVideo" style="text-align: center"></div><div id="empty-line" class="nText "><div>gasdgdsag</div>
0 votes

I am making a custom plugin for wordpress and i need to create a page in the admin menu. I already have a file called menu_list.php with the following code:

function jps_mail_list_page_entry() {
add_menu_page(
    __('JPS Mailing List'),
    'JPS Mailing List',
    'manage_options',
    'jpsNews_mailinglist',
    'jpsNews_mailing_list',
    'dashicons-email'
);
}
add_action('admin_menu', 'jps_mail_list_page_entry');

function jpsNews_mailing_list() {
    echo 'hello';
}

Now, in the plugin page i have this:

function jpsNews_activate_plugin() {
    include_once(plugin_dir_path(__FILE__).'pages/mailing-list.php');
}
register_activation_hook(__FILE__,'jpsNews_activate_plugin');

Its not working. How can i do it?

...