• Thank you for the recent updates with new features. So glad you continue to enhance the plugin.

    I have looked at your recent videos, and am not sure if the latest features will do what I need.

    I created a form with a dynamic dropdown field of workshop titles (posts). Each workshop has a different price, so I would like to display the price as text on the form once the user selects a workshop.

    One option would be to include the price in the title, which is not desirable.

    Another idea is to assign a tag to the post, and once the user selects the workshop, I would like to look up the tag assigned to the workshop, find the tag description, and display as text on the form.

    Can you confirm if functionality to do this is included in the current version? If not, some direction on how it might be accomplished?

    Thanks for your time,

    Doris

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    Hi Doris,

    Each workshop has a different price, so I would like to display the price as text on the form once the user selects a workshop.

    The dynamic field has the possibility to add extra attributes to each option in the list.

    Use the option attribute filter which will allow to set a data attribute for each post that appears in the drop-down.

    For each post, fetch it’s price value and set it as a ‘data-price’ attribute.

    When a user selects a post, trigger a script on the field change event to query the selected post data price attribute.

    To get the attribute filter see this video tutorial,
    You’ll find the filter in your field php menu in the grid UI form editor.

    Do you understand?

    Thread Starter dreilly

    (@dreilly)

    Thanks for your help!

    I understand what you are suggesting. I went ahead and added a new form field to just test the taxonomy filter, and added the filter to functions.php. I tried showing only categories with parent ID = 75, but it continues to show the full list. Shown below is what I have for the filter, modified the same way as shown in the video.

    Am I missing something, or is there a bug?

    Doris

    add_filter( 'cf7sg_dynamic_select_taxonomy_query','ClassPrice_taxonomy_query',10,3);
    /**
    * Filter dropdown taxonomy query parameter.
    * (see https://developer.wordpress.org/reference/classes/wp_term_query/__construct/)
    * @param array $args array of taxonomy query attributes.
    * @param WPCF7_FormTag $tag the field being populated.
    * @param string $cf7_key  the form unique key.
    * @return array of query attributes.
    */
    function ClassPrice_taxonomy_query($args, $tag, $cf7_key){
      //these are the label users will see when the dropdown opens.
      if('speaker-class-registration'!==$cf7_key || 'ClassPrice' !== $tag->name){
        return $args;
      }
      //use only the child terms of a parent.
      $args['parent']=75;
      return $args;
    }
    
    Plugin Author Aurovrata Venet

    (@aurovrata)

    Am I missing something, or is there a bug?

    are you sure you function is being executed properly?

    I created a form with a dynamic dropdown field of workshop titles (posts)

    initially you were using posts to populate your field, the taxonomy query filter is for fields using a taxonomy as a source.

    Enable WP_DEBUG mode and print out a message from within your function to the debug.log file to make sure your function is being executed.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    assuming this is resolved.

    Thread Starter dreilly

    (@dreilly)

    Thanks for the followup. No, I have not been successful yet. I am using debug mode, but it seems like all filters in functions.php are not executing. I may have some conflict with other Plugins so I am installing a clean site and trying to isolate the problem.

    You can close this thread if you wish. If I have more specific issues I will start a new one.

    Doris

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Thanks for the followup. No, I have not been successful yet. I

    ok, I re-opening the thread then.

    I am using debug mode

    so if you use the debug.log file configuration on your wp-config.php you can print out helpful debug messages to see if your code is being executed.

    add the following to your wp-config.php file,

    define('WP_DEBUG', true);
     if ( WP_DEBUG ) {
         define( 'WP_DEBUG_LOG', true );
         define( 'WP_DEBUG_DISPLAY', false );
         @ini_set( 'display_errors', 0 );
         define('AUTOSAVE_INTERVAL', 600 );  //seconds
     }

    basically it will ensure only debug messages appear in the log file and not on your screen when WP_DEBUG is set to true.

    This is useful to debug even a live installation.

    the log file is located in wp-content/debug.log.

    use the error_log function to write to it.

    So if you hook the following function in your functions.php file,

    add_filter( 'cf7sg_dynamic_select_taxonomy_query','ClassPrice_taxonomy_query',10,3);
    
    function ClassPrice_taxonomy_query($args, $tag, $cf7_key){
      //if this function is called, then the following message will appear in the log fie
      error_log('DEBUG: function ClassPrice_taxonomy_query called!');
      if('speaker-class-registration'!==$cf7_key || 'ClassPrice' !== $tag->name){
        return $args;
      }
      //use only the child terms of a parent.
      $args['parent']=75;
      error_log('DEBUG: function ClassPrice_taxonomy_query executed!');
      return $args;
    }

    as you can see I am writting 2 lines to the log file, the first should be printed in the log file if the function is called. However, if the 2nd line is not printed then the check in the function failed and returned before executing.

    Hope this helps to debug your code.

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

The topic ‘Display Post Tag Description Text’ is closed to new replies.