• Resolved mjtwebsites

    (@mjtwebsites)


    It would be awesome if we could use a shortcode or php function as the raised amount. I’m looking to have it dynamically pull that number from my database so it is automatically updated every time someone fills out a Caldera Form entry. I’ve got the shortcode and php function ready to go, but when I try to use the shortcode nested in your shortcode, it doesn’t work.

    Thanks!!!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author rhewlif

    (@henryp)

    Hi,
    Sounds feasible – it looks like you would just need to make a small modification to the plugin code to read the raised amount as a shortcode e.g., https://slewis.org/nested-wordpress-shortcodes/

    Thread Starter mjtwebsites

    (@mjtwebsites)

    Thanks. I tried changing line 88 in therm_shortcode.php
    from:
    $thermProperties[‘raised’] = strval($atts[‘raised’]);
    to:
    $thermProperties[‘raised’] = strval(do_shortcode($atts[‘raised’]));

    My shortcode looks like this:
    [thermometer raised=[get_total_donations field=”fld_9181836″]]

    But it didn’t work. I’ll have to look at it later. Hoping it’s something really simple!
    Thanks!

    • This reply was modified 5 years, 1 month ago by mjtwebsites.

    I had the same question fixed it by adding

    if (strpos($atts['raised'], '[') !== false) {
    	$shortcode = strval($atts['raised'])."]";
    	$atts['raised'] = do_shortcode( $shortcode);
    }

    to therm_shortcode.php on line 92.

    Please add this to the next release

    better code:

    	//raised value
    	if ($atts['raised'] == '' && !empty($options['raised_string'])){
    	    $thermProperties['raised'] = $options['raised_string'];
    	}
    	else{
    		if (!is_numeric($atts['raised'])) {
    			$shortcode = "[".strval($atts['raised'])."]";
    			$atts['raised'] = do_shortcode( $shortcode);
    		}
    	    $thermProperties['raised'] = strval($atts['raised']);
    	}
    Plugin Author rhewlif

    (@henryp)

    Thanks for this. I will look into this in a bit more detail for the next release.

    Plugin Author rhewlif

    (@henryp)

    Hi, this is now incorporated into the latest plugin update, 2.0.8.

    This doesn’t seem to work for me. I have a shortcode [total_dons] that returns a donations total and I call your shortcode like this:

    [thermometer target=”50000″ raised=[total_dons]]

    It shows the thermometer with a 0 raised value and prints the last ] as text on the page.

    Do I have to do something special in my shortcode for this to work?

    Thanks!

    Tried without the target attribute and that doesn’t work either:

    [thermometer raised=[total_dons]]

    Plugin Author rhewlif

    (@henryp)

    Hi, no as long as it outputs just a number. This should work:

    [thermometer raised=’total_dons’]

    And it does!! My shortcode does indeed only output a number calculated from the sum of Gravity Forms entries’ totals in several donation forms. It’s a moderately complex shortcode actually but the ouput is not ??

    I didn’t want the client to have to update this manually. So thank you so much! That really helps.

    • This reply was modified 4 years, 6 months ago by pixelyzed.
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Feature Request: Shortcode or PHP Function for Raised Amount’ is closed to new replies.