This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

WordPress integration using Advanced Code


  1. yuniar

    I haven't tried this actually, but one of MachForm user seems to be able integrating MachForm into WordPress post using a neat trick.

    Check it out here:
    http://www.spidshedgroup.com/programming/machform-shortcode-for-wordpress

    Thanks to Pete for this!


    MachForm Founder

    Posted 15 years ago #
  2. peteb
    Member

    You can view a sample of the integration at http://www.spidshedgroup.com/contact

    Posted 15 years ago #
  3. mindseye
    Member

    That website is not up. Is there another link that has successfully integrated MachForm into WordPress?

    Posted 14 years ago #
  4. 13floornetwork
    Member

    I have tried all the other post and still can not use the advanced code method in WordPress. The link in the previous post is no longer good. Why does the advanced code not work?

    Posted 14 years ago #
  5. yuniar

    Hmm.. the site seems down. Hopefully they'll get it up soon.
    Fortunately I have a cache of the post. Below is the post by Pete:
    ------------------------------------------------------------------

    AppNitro has a slick PHP application called MachForm that lets you build forms on-the-fly in about 15 seconds. Once the user submits the form, it can e-mail their input to you, store it in a database, or both. It also has some neat integration and embedding features that let you put your form on literally any page.

    In case you happen to be using both MachForm and WordPress, here’s a script I wrote that will let you to easily embed your forms into any post or page using shortcode.

    All you need to do is paste this snippet into your functions.php file (inside of your theme directory) and customize a few of the paths. Once you’ve added the snippet, you can embed your form by typing [machform id=id_here] into the editor.

    // Shortcode for MachForm Embed
    function machform_func($atts) {
       extract(shortcode_atts(array('id' => 1), $atts));
    
       // MachForm Requirements
       // Get this information from Embed Code > Advanced inside MachForm.
       require("/your/path/here");
       $mf_param['base_path'] = 'http://your_base_path_here/';
    
       // Load Form ID from Short Code
       $mf_param['form_id'] = $atts['id'];
    
       // Begin Output Buffer
       ob_start();
       display_machform($mf_param);
       $form = ob_get_contents();
       ob_end_clean();
    
       // Return the Form
       return $form;
    }
    add_shortcode('machform', 'machform_func');

    MachForm Founder

    Posted 14 years ago #
  6. bmex63
    Member

    Hi everyone,

    I am using the code above in my functions.php file. I also made the modifications listed in this post: http://www.appnitro.com/forums/topic/problem-with-validate_username-function#post-4616

    The form displays fine but now I am experiencing the dreaded:
    Session Expired error

    on submission. Where should we add this code in my WordPress template?
    <?php session_start(); ?>

    Thanks,
    Ben

    Posted 14 years ago #
  7. redityo

    Hi Ben,

    Try to add that code on the first line of "functions.php" file (the file when you put the snippet code).


    MachForm Support

    Posted 14 years ago #
  8. KnockOuts
    Member

    I receive this error when trying to use the advanced code:

    select form_name, form_description, form_redirect, form_success_message, form_password, form_unique_ip, form_frame_height, form_has_css, form_active, form_captcha, form_review from ap_forms where form_id='1' Query failed: Table 'rreed_wordpress.ap_forms' doesn't exist

    Posted 14 years ago #
  9. KnockOuts
    Member

    Nevermind- fixed the database issue.

    Posted 14 years ago #
  10. ArenCambre
    Member

    This doesn't work. When pasting this before the ?> at the end of wp-includes/functions.php, I get this error:

    Fatal error: Call to undefined function add_shortcode() in /[path to WordPress]/wp-includes/functions.php on line 3364

    Apparently add_shortcode is not available when functions.php is executed. Where is the proper place to put this code?

    EDIT: it appears to work if I add add_shortcode(’machform’, ‘machform_func’); to wp-settings.php.

    Posted 14 years ago #
  11. forechecker
    Member

    I see the same issues as KnockOuts did...I get this:

    select form_name, form_description, form_redirect, form_success_message, form_password, form_unique_ip, form_frame_height, form_has_css, form_active, form_captcha, form_review from ap_forms where form_id='1' Query failed: Table 'jcleggph_jcleggclientsite.ap_forms' doesn't exist

    But he didn't leave the fix...what was the database issue and/or how do I resolve this?

    Thanks so much!

    Posted 14 years ago #
  12. yuniar

    Have you added the code above into your functions.php file?


    MachForm Founder

    Posted 14 years ago #
  13. skindu26
    Member

    Hi, i fixed it by adding the merging the machform database to wordpress database; in other words, grant all privileges to the wordpress database user to machform database.

    Posted 14 years ago #
  14. leisurepublishing
    Member

    I'm getting the same error as @KnockOuts and @forechecker. I added the WP user with full privileges to the machform DB but this did not fix the issue. Advice?

    Posted 14 years ago #
  15. canton
    Member

    Hi,

    I'm just now trying to figure out some ways to resolve this problem and I'm guessing that this is at the root:

    If you are trying to use the "advanced form code" on a wordpress page, which includes machform.php, then I suspect the problem is that wordpress' config file conflicts with machform's config file. Both of them happen to use the exactly same PHP definitions for configuring their databases, e.g.

    define('DB_NAME','xyz')
    define('DB_USER','xyz')

    So if wordpress' config gets loaded first, its definitions "win" and override the definitions in machform. The result is that machform tries to look for its data inside of the wordpress DB instead of the machform DB.

    At the moment, the only work-arounds I can think of are:

    1) As skindu26 suggested, merge both databases into a single database so that their definitions no longer conflict, or
    2) Do a global search and replace through the machform code to assign new definition names, e.g.

    define('MACH_DB_NAME', 'xyz');

    Both are kind of 'bleah' solutions.

    Anyone come up with something better?

    Posted 14 years ago #
  16. canton
    Member

    Just a quick update,
    It's ugly, but here's how I got wordpress and machform to integrate nicely:

    1) added the shortcode function pasted above by yuniar, and added shortcodes to my wordpress pages that needed forms, e.g.
    [machform id=1]

    2) modified my wordpress page.php template to include the following line at the VERY TOP of the file (must appear before anything is output to the browser)
    <? session_start(); ?>

    3) Did a search and replace through the machform application directory to replace all instances of:
    DB_NAME with MACHDB_NAME
    DB_PASSWORD with MACHDB_PASSWORD
    DB_HOST with MACHDB_HOST

    (At the time I wrote this post, this only impacted 3 files.)

    Obviously, the biggest disadvantage here is that anytime machform is upgraded, step 3 must be repeated once the source files are overwritten.

    Here's the final result in action: A wordpress page with an 'advanced' machform implementation:

    http://www.nmschoolforthearts.org/contact/

    Posted 14 years ago #
  17. yuniar

    canton -- thanks for the update.

    Actually, what you've done is the best method for now. It has drawback indeed, that you need to re-do step #3 when new version of MachForm released.

    However, your forms should be working just fine.


    MachForm Founder

    Posted 14 years ago #
  18. leisurepublishing
    Member

    Well, it doesn't work with Wordpress Mu (2.9.2 is my version). I'm getting this error on the page-

    Fatal error: Cannot redeclare validate_email() (previously declared in /home/foo/public_html/wp-includes/wpmu-functions.php:886) in /home/foob/public_html/forms/includes/common-validator.php on line 221

    I guess Mu and Machforms share a common function name...ugh.

    Posted 14 years ago #
  19. dustydean
    Member

    Hey guys,

    I've followed Canton's instructions above and my page displays this error: "Could not connect:".

    I've also followed instructions in another thread of modifying the "includes/db-core.php" file and embed code. (http://www.appnitro.com/forums/topic/problem-with-validate_username-function?replies=7#post-4652)

    I get the same "Could not connect:" error both times.

    skindu26 mentions above that they had to modify MySQL user privileges to Grant all privileges to the Wordpress database user to Machform database.

    Is this something I need to do here, or am I barking up the wrong tree? If so, what commands/privileges would I need to grant?

    Posted 14 years ago #
  20. yuniar

    Hi dusty,

    We got your support ticket. We'll help you there.


    MachForm Founder

    Posted 14 years ago #

RSS feed for this topic

Reply »