WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Contact Form 7] Add action to the additional settings (2 posts)

  1. duncmorley
    Member
    Posted 2 years ago #

    I am wanting to add the following action/hook to the addition settings box on the contact form 7 plugin:

    add_action( 'wpcf7_before_send_mail', 'wpcf7_callback' );

    I cannot get this working at all.

    On submit of the form i would like the function "wpcf7_callback" to trigger and thought this would be the way. I cannot put this add_action in the functions.php file as i need to call a different functions for different forms throughout the site.

    Does anyone have any suggestions?

  2. Colir
    Member
    Posted 2 years ago #

    don't know if i understand well but you can put this add_action in the function.php file, and lookup the form title to switch to different action

    function wpcf7_before_action($cfdata) {
    	$formtitle = $cfdata->title;
    
    	if ( $formtitle == 'name-of-your-form') {
             //do action for this form
    	}
    if ( $formtitle == 'name-of-your-form') {
             //do action for this form
    	}
    
    }
    add_action('wpcf7_before_send_mail', 'wpcf7_before_action',1);

Topic Closed

This topic has been closed to new replies.

About this Topic