Title: callback function and class in shortcode
Last modified: January 13, 2022

---

# callback function and class in shortcode

 *  Resolved [pawandongoloutside](https://wordpress.org/support/users/pawandongoloutside/)
 * (@pawandongoloutside)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/callback-function-and-class-in-shortcode/)
 * How to add callback function and class in contact form short code [cf7-hcaptcha]?

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [kaggdesign](https://wordpress.org/support/users/kaggdesign/)
 * (@kaggdesign)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/callback-function-and-class-in-shortcode/#post-15255129)
 * What do you want to do? To redefine the shortcode fully?
 * You can simply use the statement:
 *     ```
       add_shortcode( 'cf7-hcaptcha', [ $this, 'my_cf7_hcaptcha_shortcode' ] );
       ```
   
 * after `\HCaptcha\CF7` class initialization, which happens on `plugins_loaded`
   action with the earliest priority: -PHP_INT_MAX.
 * So, you can add your own shortcode like this
 *     ```
       class My_CF7_Shortcode {
   
       	public function __construct() {
       		add_action( 'plugins_loaded', [ $this, 'add_shortcode' ] );
       	}
   
       	public function add_shortcode() {
       		add_shortcode( 'cf7-hcaptcha', [ $this, 'my_cf7_hcaptcha_shortcode' ] );
       	}
   
       	public function my_cf7_hcaptcha_shortcode() {
       		// Do something...
       	}
       }
       ```
   
 * This will redefine shortcode by itself, but all the processing (verification)
   will still work from the hCaptcha plugin.

Viewing 1 replies (of 1 total)

The topic ‘callback function and class in shortcode’ is closed to new replies.

 * ![](https://ps.w.org/hcaptcha-for-forms-and-more/assets/icon.svg?rev=3026321)
 * [hCaptcha for WP](https://wordpress.org/plugins/hcaptcha-for-forms-and-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/hcaptcha-for-forms-and-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/hcaptcha-for-forms-and-more/)
 * [Active Topics](https://wordpress.org/support/plugin/hcaptcha-for-forms-and-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/hcaptcha-for-forms-and-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/hcaptcha-for-forms-and-more/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [kaggdesign](https://wordpress.org/support/users/kaggdesign/)
 * Last activity: [4 years, 4 months ago](https://wordpress.org/support/topic/callback-function-and-class-in-shortcode/#post-15255129)
 * Status: resolved