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

MachForm integration into WordPress Page as a PHP Page Template


  1. mattdmin
    Member

    I've been working on getting MachForms into a Wordpress page template as an individual PHP file, as Wordpress does not allow adding PHP code to pages or posts unless you install a plugin(which can be very unsecure). I've got it working after I installed my MachForms SQL DB into the original Wordpress DB, but had to comment out some code in the Wordpress user.php file to actually get it working. I don't want to do it this way, as the validation code is needed for security IMO.

    The code I commented out in my Wordpress /wp-includes/user.php is:

    /**
    * Checks whether an username is valid.
    *
    * @since 2.0.1
    * @uses apply_filters() Calls 'validate_username' hook on $valid check and $username as parameters
    *
    * @param string $username Username.
    * @return bool Whether username given is valid
    */

    /* Commented here
    function validate_username( $username ) {
    $sanitized = sanitize_user( $username, true );
    $valid = ( $sanitized == $username );
    return apply_filters( 'validate_username', $valid, $username );
    */

    Anyone have any suggestions on how to modify this to work with MachForms? If so, I figured out a pretty smooth fix, but this is where I am stuck. It seems that the uservalidation is looking for a table called mywordpressdb.app_forms

    Posted 13 years ago #
  2. mattdmin
    Member

    I figured it out with one small fix, only problem is that it doesn't keep the form in the WordPress CMS, it goes to the form itself, but keeps it where I placed the PHP file in the Wordpress directory. What a pain.

    http://www.appnitro.com/forums/topic/problem-with-validate_username-function?replies=12

    Posted 13 years ago #
  3. yuniar

    Do you have any URL I could check or test?


    MachForm Founder

    Posted 13 years ago #
  4. mattdmin
    Member

    I actually took it down for the time being. I figured out why it was only coming up as the form page itself when I linked, it is because it is supposed too! It was merely calling the form itself with no other PHP or HTML involved. I'm currently building a page template that will contain the form, just haven't had the time.

    But I did get MachForms integrated into WordPress, and will post as I get a full template done.

    Posted 13 years ago #
  5. mattdmin
    Member

    Took me a about 10 minutes to write up a simple WordPress template to integrate MachForms into WorPress as a regular PHP file, I also integrated google translation into the MachForm itself. Here is an example of the WordPress template you build in your current WordPress theme. For those of you who do not know how to build a custom Wordpress Template, there is tons of info on the net with how to videos and such.

    Here is a great video tutorial: http://www.wordpressmax.com/customize-wordpress/custom-page

    Hope this helps.

    <?php
    /*
    Template Name: Experimental
    */
    ?>
    <?php get_header(); ?>

    <div id="wrap">
    <div id="content" class="fullwidth">

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <div id="page-<?php the_ID(); ?>" <?php post_class(); ?>>

    <h2><?php the_title(); ?></h2>
    <?php edit_post_link(__( 'Edit', 'themezee_lang' )); ?>

    <div class="entry">
    <?php the_post_thumbnail('medium', array('class' => 'alignleft')); ?>
    <?php the_content(); ?>
    <?php require("/home/acctname/public_html/forms/machform.php");
    $mf_param['form_id'] = 1;
    $mf_param['base_path'] = 'http://www.yourdomain.com/forms/';
    display_machform($mf_param); ?>

    <div class="clear"></div>
    <?php wp_link_pages(); ?>
    </div>

    </div>

    <?php endwhile; ?>

    <?php endif; ?>

    </div>
    </div>
    <?php get_footer(); ?>

    Posted 13 years ago #

RSS feed for this topic

Reply