GiveWP PHP Constants
GiveWP comes with a few useful PHP Constants for developers. These should be placed in your wp-config.php
file and only if you understand exactly what they do and how they affect your website.
GiveWP’s constants are created to give developers advanced abilities to interact with GiveWP in ways that would be potentially dangerous under normal circumstances. PHP constants are a very powerful feature of PHP, and of WordPress itself. Here’s a few important resources if you want to learn more about constants:
- PHP Manual on Constants and “Magic Constants”
- WordPress.org on editing your wp-config.php file
- A laundry list of constants available in WordPress by WPEngineer.com
GIVE_SLUG
define('GIVE_SLUG', 'ways2give');
The `GIVE_SLUG` gives you an easy way to change the slug for all your GiveWP single forms and the Archive page. The default is `donations`. So using the example above, the default would change from this:
https://yourdomain.com/donations/test-form
to this:
https://yourdomain.com/ways2give/test-form
Please note that this will have no impact on the “Default” permalink style, but on all others it will appear like the above. Also note that after making this change, it’s best to refresh your permalinks to see the change affected.
GIVE_API_VERSION
define( 'GIVE_API_VERSION', 'v1' );
Currently there is only one version of the GiveWP API. But if you have any trouble activating the API normally (see our documentation on that), you can set this global to force the version.
GIVE_USE_PHP_SESSIONS
define( 'GIVE_USE_PHP_SESSIONS' , false);
Occasionally you might have trouble with donors viewing their receipts or issues with sessions because your host does not support or handle PHP Sessions very well (or at all) or there is a caching layer that is preventing GiveWP from setting donor session. In this case, it may be useful to disable PHP Sessions with this constant. In this case, all donor session activity is stored in the database temporarily. For most sites, this won’t be any issue. If you have a heavily trafficked site, disabling PHP Sessions may result in very heavy database usage so keep an eye on that.