• Resolved giandani

    (@giandani)


    Hi,
    I’ve a request that could really keep me out of a lot of maintenance.

    I’ve a form about some courses registration where the user can select a course, fill in all the required fields, see the course amount that has been calculated and then submit.

    The issue is that the courses may vary and also their costs.
    I wanted to understand if there’s a way to link the Select to some sort of an external database of any kind in order to retrive the updated list of courses instead of updating manually the form each and every time.
    Note that based on the course type (Select 1) there could be further Selects for Course Level and Ages that may or may not apply. (i.e. Kids Course – Age 9-11 – Basic Level ; Adult Course, Advanced Level).

    Something like a GET would be nice ??

    Giandani

    • This topic was modified 3 years ago by giandani.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Dimitris – WPMU DEV Support

    (@wpmudev-support6)

    Hello @giandani

    Query parameters can only be used to pre-populate the field value, for example:

    View post on imgur.com


    but for dynamically getting all options I’m afraid that you will have to custom code it using the provided API:
    https://wpmudev.com/docs/api-plugin-development/forminator-api-docs/

    Thank you,
    Dimitris

    Thread Starter giandani

    (@giandani)

    Thanks Dimitris,
    but pre-populate will not work for me, I need something a bit more complex like a query on post type and terms to fill Select and on their relative post data to fill Hidden fields for Calculation.

    About the custom coding, that won’t be feasible for me: haven’t got the skills to code in php, nor the time to learn (have to deploy next week).

    Thanks anyway,
    Giandani

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @giandani

    Thank you for the update.

    I am afraid the only option would be writing a custom code to update the field using the API.

    Forminator does have some hooks, this is an example, to update a hidden field and replace a fixed value with a Custom field value:

    <?php 
    
    add_filter( 'forminator_field_hidden_field_value', function( $value ){
    
    	if( $value === 'custom_email' ){
    		$post_id = get_queried_object_id();
    		$custom_email = get_post_meta( $post_id, 'custom_email', true );
    		$value = $custom_email;
    	}
    	return $value;
    } );

    But either of those available hooks will require PHP code since you would need to fetch the database.

    Best Regards
    Patrick Freitas

    Thread Starter giandani

    (@giandani)

    Many thanks for the tip.
    I think for the moment I’ll release as-is with manual update, and well… I’ll learn some php for future improvements ??

    Best,
    Giandani

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @giandani

    You are welcome,

    I am marking this as resolved, but feel free to ping us if you have any additional questions.

    Best Regards
    Patrick Freitas

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Retrieve data from external source’ is closed to new replies.