最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Create a form and have custom menu display based on user answers?

programmeradmin0浏览0评论

I want to create a "User Guide" form that will allow users to answer questions and pick the categories that they are interested in viewing. After they pick their categories and answer the questions I would like it to redirect them to a page with a customized sidebar menu with the categories that they chose.

I am using Gravity Forms and it has let me have users pick categories they are interested in, however, I do not know how to have it connected with a sidebar menu customized to the answers they chose.

Any suggestions on a plugin or code I could use would be greatly appreciated, thank you.

I want to create a "User Guide" form that will allow users to answer questions and pick the categories that they are interested in viewing. After they pick their categories and answer the questions I would like it to redirect them to a page with a customized sidebar menu with the categories that they chose.

I am using Gravity Forms and it has let me have users pick categories they are interested in, however, I do not know how to have it connected with a sidebar menu customized to the answers they chose.

Any suggestions on a plugin or code I could use would be greatly appreciated, thank you.

Share Improve this question edited Sep 18, 2019 at 18:34 Jasmine Vary asked Sep 16, 2019 at 16:10 Jasmine VaryJasmine Vary 11 bronze badge 2
  • Please provide a bit more detail. Do you already have an application environment? Are you using a database on the back-end? If so, which database? Do you have a plan to use cookies, sessions, database, something else, to pass values to the form? Your answers to these questions could drive the potential answers. – Mike Baxter Commented Sep 16, 2019 at 19:37
  • @MikeBaxter I edited my question, please let me know if I still need to provide more detail. Thank you. – Jasmine Vary Commented Sep 19, 2019 at 20:05
Add a comment  | 

2 Answers 2

Reset to default 0

Easy way to achieve your goal, use WPForms This have a feature like Multi page form

What you want to do is relatively easy, if you are familiar with Wordpress Theme modifications. The following will assume you are at least comfortable with PHP, and hopefully Wordpress Theme modification. If not, I can provide some additional links in subsequent updates to this answer ... just let me know.

First step: Gravity Forms documentation has instructions for "Populating a Form Based On Another Submission". Specifically, see their section on "Setting up the first form to send data using confirmations". Use those instructions to pass your form field(s) to the desired the desired page(s) within your site.

Next: You will need to modify your theme's page template(s) (or create a child theme) to use those parameters for calculating which custom nav menu, dynamic sidebar, or other object to display. Use $_GET to extract your parameters similar to the following:

if (isset($_GET['Param_A'])){
    switch ($_GET['Param_A']){
        case "User_Response_A":
            dynamic_sidebar( 'custom-sidebar-a' );
            break;
        case "User_Response_B":
            dynamic_sidebar( 'custom-sidebar-b' );
            break;
        case "User_Response_C":
            dynamic_sidebar( 'custom-sidebar-c' );
            break;
        default:
            dynamic_sidebar( 'custom-sidebar-WHATEVER' );
    } // end switch
} // end if

If you are comfortable with PHP, but not so comfortable with Wordpress Theme modifications, you could use an intermediary plugin like Insert PHP Code Snippet to add a modified version of the PHP I provided to any widget area.

If you want to get really tricky, you could use the $_GET value to set a cookie value, then use AJAX calls to change the sidebar/menu content in real-time. That is far more complex to setup. Please submit another Question, if you wanted to go that route.

发布评论

评论列表(0)

  1. 暂无评论