How to Add Custom Code to WP Simple Pay
Do you need to add specific functionality to your WP Simple Pay payment forms not available in the plugin settings?
Just make sure to back up your site first and test on a staging or local site first before making changes to your live site.
From there, simply follow the Beginner’s Guide to Pasting Snippets from the Web into WordPress from WPBeginner.
Using Our Code Snippet Library
We also have a code snippet library for WP Simple Pay. This library holds example code making use of various filter and action hooks available in the plugin.
We recommend using the free plugin WP Code when adding code from our snippet library.
To use one of our code snippets with WP Code, go to Code Snippets → +Add Snippet and select the Add Your Custom Code snippet.
Be sure to select the PHP Snippet Code Type, and to toggle your snippet to Active after you have made any necessary changes and are ready to make the code live. All other settings can remain at their defaults.
Here are just a few of the code snippets available:
- Replace translatable text (i.e. the coupon “Apply” button and “remove” link text). Alternatively, use a translation plugin such as Loco Translate.
- Conditionally dequeue plugin scripts and styles.
- Create a new WordPress user using the email address of one-time or subscription charges.
- Add custom template tags to be used with the payment confirmation messages.
- Change the custom amount field to “number” type to show the decimal key on iOS & mobile browsers.
Browse the WP Simple Pay code snippet library on GitHub.
Contributing to the Code Snippet Library
If you’re a developer and want to contribute a code snippet, please open up a pull request on the GitHub repository.
Note, we do not recommend altering WP Simple Pay code directly, as it will be overwritten with any plugin update.
Is there a place in our code that we could add another hook that would be useful to you? Please let us know.
Still have questions? We’re here to help!