WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Donation Plugin with Goals and Paypal IPN by NonprofitCMS.org
Grabbing Total Amount Collected for Use in PHP (7 posts)

  1. sammcdade
    Member
    Posted 1 year ago #

    I have created php code that takes in a number and returns the proper image in a sequence of images based on the current range the $currentSupport number is within.

    The code is running perfectly except for the fact that I need to take in the number that is generated by [wpdonatecollected cid=001]. How do i get that number inside of my PHP code?

    http://wordpress.org/extend/plugins/wordpress-donation-plugin-with-goals-and-paypal-ipn-by-nonprofitcmsorg/

  2. Kayjey
    Member
    Posted 1 year ago #

    As the WordPress tags are processed AFTER the PHP is executed, you will not be able to get the amount into your PHP script. I would suggest to go inside the PHP of the script and add that functinality you need directly into the plugin.

  3. martvisser
    Member
    Posted 1 year ago #

    I encountered the same problem when writing a additional shortcode in my 'functions.php' file for the custom theme i build.
    This works fine for me:

    do_shortcode('[wpdonatecollected cid='. $value .']');

    Where $value is the variable containing the cid.

  4. sammcdade
    Member
    Posted 1 year ago #

    That is exactly how I did it and got it working! I should have posted to say I had solved the problem. I'm glad you found the solution as well!

  5. leoly
    Member
    Posted 1 year ago #

    more explanations please if the cid = 001, where do you put that info?

    like do_shortcode('[wpdonatecollected cid='. 001 .']');

    or

    do_shortcode('[wpdonatecollected cid='. 1 .']');

    or ?

    thanks

  6. martvisser
    Member
    Posted 1 year ago #

    Normally you would like to use this code with a user-defined cID, otherwise I don't really see a use for it, but when you would like your PHP code to always use the same cID you could use the following:

    <?php
    $cID = 1;
    do_shortcode('[wpdonatecollected cid=' . $cID . ']');
    ?>

    Without use of the $cID variable you could use the following:

    <?php
    do_shortcode('[wpdonatecollected cid=1]');
    ?>

    The interface for the plugin shows the cIDs with leading zero's (e.g. 001), but in the database and in the PHP code it's just an integer (e.g. 2 or 15). So in PHP code just use the cID without leading zero's.

  7. leoly
    Member
    Posted 1 year ago #

    thank you for explaining.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic