You should be able to generate discount codes within your callback function by using the edd_add_discount()
function. You can learn more about this function here on the EDD Codex to see what specific data you need to pass to the function.
However, edd_complete_purchase
might not be the right action to hook to. If you only want specific codes to be generated when specific payment types (PayPal) are successfully charged, you might want to instead hook to edd_before_payment_status_change
. This is called in edd_update_payment_status()
, which you can also see on the EDD Codex here, and should let you only run edd_add_discount()
if the $new_status
within edd_update_payment_status()
is 'published'
(or otherwise for a successful payment, instead of 'failed'
or 'pending'
).
Related Posts:
- Init action hook running late after PayPal’s return url?
- Sensible location for IPN Callback script
- How to create a digital product download link that can’t be used twice?
- Creating open content area and restricted content area
- Set the payment processor callbacks to a plugin
- Is there a limit on making calls to WordPress.org API’s?
- Vagrant script to setup all the common PHP / WordPress version combinations
- register_uninstall_hook() vs uninstall.php – which one is better way to handle plugin uninstallation script?
- How to make method from plugin available in theme?
- Email verification for new users
- How to implement bulk actions in my plugin?
- How to properly sanitize strings for update_option()
- Turn Shortcode Gallery into Carousel in WordPress 4.4
- Dashboard like meta boxes in my plugin – how to save their position and open/closed state?
- Using AJAX in FrontEnd with WordPress Plugin Boilerplate (wppb.io)
- How do I implement a jQuery UI dialog modal in a WP plugin?
- WP Cron – Run Cron after evey 15 minutes at a specific time for the next three hours
- Using a Theme inside a Plugin directory
- Authoritative answer on which boots first – Plugins or Themes?
- How to Add Font Awesome Icons to WordPress Menus?
- register_activation_hook() not activate plugin
- Problem with sorting entries in a plugin’s admin interface table
- How to prevent specific plugin files or subfolders from appearing under “plugin files” listing
- How to create custom home page via plugin?
- Featured Image not showing in admin
- Hello dolly type plugin that allows people to add their own
- Whats the difference between blog_info(‘stylesheet_url’) difference get_stylesheet_uri()
- Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?
- using get_option to add a different js
- Add Submenu Link in add_submenu_page That Opens in a New Window
- How to display non-page / post content
- WordPress Hook for user account activation in normal Wp (not MU)
- How to check if a stylesheet is already loaded?
- Mixing Regular Javascript With jQuery in a Plugin
- Where to call wp_enqueue_script in a plugin with custom template?
- Create & Save multiple Meta-boxes
- How to fetch all images from a WordPress draft using PHP?
- Can’t get woocommerce_get_price_html to work [closed]
- jQuery selectors for editor elements safe to use?
- wp_set_object_terms not updating database without a die()
- WordPress form action – doesn’t work
- parse content from wikipedia article replacing search term with the title of article
- Fatal error: Uncaught Error: Call to undefined function get_option()
- Strange Situation When Try To Retrieve Github Gist Using wp_remote_get
- Thickbox doesn’t respect dimensions when used in admin [duplicate]
- jQuery does not enqueue for my purpose… (before an inline script in the footer)
- how to get all the child category name in a specified category name?
- Can I add custom css to an mu-plugin?
- Change WooCommerce Email Header using custom plugin
- Why is my plugin version 0.1?
- WP Plugin Running before jQuery
- How to include jQuery into my plugin so I can use it on plugin page?
- Prevent WordPress automatically processing certain URL queries
- How to get the current page Title and Page URL in footer.php
- insert query on a custom table using ajax with jQuery plugin Jeditable
- WordPress multisite,use same cookies across all website?
- How to check via conditional tags for a single plugin page?
- How to add search form in main page body?
- How to save post meta as an array in Gutenberg?
- WordPress Rest API with rest_do_request, possible race condition?
- Need help about understand api, wp, $ syntax in WordPress plugin script
- How to disable a jQuery plugin on WordPress plugin page
- Is it possible to use WP-CLI in a plugin (or theme)?
- WP_NAV_MENU filter targets all menus
- Load php file with jquery in single.php
- Restore svn trunk of my plugin repository to the initial state?
- Anyone using unzip_file successfully? It uploads the zip but doesn’t extract it!
- WP 3-way voting system: On to something! Please help!
- Why is the expected file not being deleted?
- How to determine which capability to use?
- How to use attributes in competent of Gutenberg
- How does one update complex options?
- How to write a custom shortcode name book?
- Hook to execute after deleting a Custom Taxonomy
- Forbidden Error in ajax call with wordpress
- How to use setAttributes outside of the edit function return
- WP plugin svn checkout 429 error “Too many requests”
- get the term_id of current taxonomy page
- Custom non-template page on front end fails to render
- Add custom parameter for custom user role
- Post is uncatagorized in publish_post action
- WordPress Filesystem create CSS-File – get Shortcode ID for Name
- WordPress Iframe for blog image
- How to add admin.php to WP Admin Menu Link
- Add the Twitter Bootstrap framework for the development of my plugins
- Code to add template to page
- Single_template for a custom post type created from a plugin is returning an empty page
- How to retrieve custom profile fields associated with different users
- Convert each new line in the textfield as a new value in an array
- Navigate to external link if last page or post in a category
- How do I control the list of Pages an author can see?
- Is there a general way to get a themes primary colour?
- Custom query not working in plugin admin page
- How to work with AJAX and WordPress?
- How to Register/Link to .js Files in WordPress Dynamicaly in Header.php
- Add Page With Parent ID
- Thumbnails for media Library images
- Developing Themes on WordPress, Looking for Excellent Tutorials [closed]
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- upload script in plugin development [duplicate]