Title: problem with displaying forms dynamically in shortcode
Last modified: August 10, 2018

---

# problem with displaying forms dynamically in shortcode

 *  [Mostafa Shahiri](https://wordpress.org/support/users/mostafadeveloper/)
 * (@mostafadeveloper)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/problem-with-displaying-forms-dynamically-in-shortcode/)
 * Hi
 * I am creating a plugin that uses shortcode to load forms. It has two forms: 1)
   input form 2)output form
    To add shortcode to my plugin, I use following code:
 * function myplugin_maker_makeshortcode() {
 *  ob_start();
    myplugin_maker_apply(); html_form_code($result); return ob_get_clean();
 * }
    add_shortcode(‘myplugin_maker_form’,’myplugin_maker_makeshortcode’);
 * ——–
    Input form variables are sent to myplugin_maker_apply() function to check
   and generate proper output.The html_form_code() is the function that shows forms
   based on $result. If $result is empty, it shows input form else shows output 
   form, But output values are set in myplugin_maker_apply function. So I try to
   call html_form_code() in the myplugin_maker_apply function, but as output I receive
   both input and output forms. How can I solve this problem to show just one of
   the forms based on $result value.
 * Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Rachna](https://wordpress.org/support/users/rachna90/)
 * (@rachna90)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/problem-with-displaying-forms-dynamically-in-shortcode/#post-10580799)
 * Hi,
    I recommend asking at [https://developer.wordpress.org/plugins](https://developer.wordpress.org/plugins)
   so the plugin’s developers and support community can help you with this. Thanks.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/problem-with-displaying-forms-dynamically-in-shortcode/#post-10582046)
 * $result is out of scope or not defined in your shortcode handler. There are at
   least a couple ways to determine if a form has been submitted in order to decide
   whether to display the results or the initial form. One way is to have your form
   use POST method. Then check the request type in $_SERVER[‘REQUEST_METHOD’]. If
   it’s “POST”, handle the form submit, else show the form (because the request 
   was probably “GET”). Or you can just check for a required form field in $_GET
   or $_POST (depending on the method used by your form).
 * [@rachna90](https://wordpress.org/support/users/rachna90/) – thank you for trying
   to help, however the link you posted does not have any support available like
   you imply. I imagine you simply had the wrong link in your clipboard. Happens
   all the time, no worries, just FYI. In any case, the OP has their own plugin,
   so there is no dedicated forum to send them to.
 *  [Rachna](https://wordpress.org/support/users/rachna90/)
 * (@rachna90)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/problem-with-displaying-forms-dynamically-in-shortcode/#post-10582880)
 * Hello,
 * Sorry, that link didn’t help.
    -  This reply was modified 7 years, 10 months ago by [Rachna](https://wordpress.org/support/users/rachna90/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘problem with displaying forms dynamically in shortcode’ is closed to 
new replies.

## Tags

 * [forms](https://wordpress.org/support/topic-tag/forms/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 3 participants
 * Last reply from: [Rachna](https://wordpress.org/support/users/rachna90/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/problem-with-displaying-forms-dynamically-in-shortcode/#post-10582880)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
