Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Sanjeev Veloo4,713 Points
Latest Ninja Forms does now show PHP code? Only shortcode?
The latest ninja forms plugin doesn't seem to show php code anymore, just the shortcode for using the form? What alternative route should i use?
Samuel Glister12,471 Points
What is it you are trying to do with your form? Most of what you probably want to achieve can probably be done so with a shortcake.
If you want to add your form directly into the template file you can do so with this
<?php echo do_shortcode('[your-form-id]') ?>
I know this is an old topic but I found a way to make Ninja Forms work, you simply have to put:
<?php Ninja_Forms()->display( 1 ); ?>
(where 1 = the id of the form you want to use) into your code inside of the modal-body div. Full footer.php code below:
<hr> <footer> <p>© <?php bloginfo( 'name' ); ?> <?php echo date('Y'); ?></p> </footer> </div> <!-- /container --> <div class="modal fade" id="contactForm"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">Contact Us</h4> </div> <div class="modal-body"> <?php Ninja_Forms()->display( 1 ); ?> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal --> <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script> <?php wp_footer(); ?> </body> </html>
Hopefully this helps someone coming to this lesson in the future!
An alternative route from Ninja is and you still want it to be free is WP Forms. Its pretty basic, but easy to make responsive. If you can afford it, I would use Gravity forms.
Bradley Maravalli8,927 Points
My solution was to use the Contact Form 7 plugin and place the following code within the modal body class.
<?php echo do_shortcode( '[contact-form-7 id="95" title="Contact form 1"]' ); ?>
I've installed Contact Form and coppied the shortcode within the modal body class. But in order to it work properly, i've had to add this WP function: do_shortcode
<?php echo do_shortcode('[contact-form-7 id="155" title="Contact form 1"]'); ?>