Support » Plugins » Hacks » Replace function

  • Hi! I know English not very good, so I will write briefly.
    Can I change function in other module by my own function?
    For example, I need to replace ‘si_captcha_comment_form_wp3’ function in Si-captcha module. Can I do this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi 13rust,
    Unless you rewrite the function in si-captcha.php, which is a bad idea, it is not possible to do this since si_captcha_comment_form_wp3() does not implement any filters.

    Good luck!

    Moderator Sergey Biryukov


    WordPress Dev

    You can “unhook” the plugin’s function and replace it with your own:

    function my_captcha_comment_form() {
    	global $si_image_captcha;
    	// ...
    	remove_action('comment_form', array(&$si_image_captcha, 'si_captcha_comment_form'), 1);
    function replace_si_captcha_comment_form_wp3() {
    	global $si_image_captcha;
    	remove_action('comment_form_after_fields', array(&$si_image_captcha, 'si_captcha_comment_form_wp3'), 1);
    	remove_action('comment_form_logged_in_after', array(&$si_image_captcha, 'si_captcha_comment_form_wp3'), 1);
    	add_action('comment_form_after_fields', 'my_captcha_comment_form', 1);
    	add_action('comment_form_logged_in_after', 'my_captcha_comment_form', 1);
    add_action('init', 'replace_si_captcha_comment_form_wp3');

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Replace function’ is closed to new replies.