В моем плагине Wordpress у меня есть класс php, в котором я хочу подключиться к контактной форме 7 hook wpcf7_mail_sent
.Но это не работает для меня.
do_something () не входит в процесс перехвата.
Я думаю, что я зарегистрировал этот перехват в неправильном месте (__construct()
).
Не могли бы вы мне помочь?
<?php
class MyCF7 {
public function __construct() {
add_action( 'wpcf7_mail_sent', array( $this, 'do_something' ) );
}
public function do_something() {
}
}
Расширение:
<?php
/*
Plugin Name: Contact Form 7 - My plugin
Description: My Integration
Version: 1.0
*/
class MyCF7 {
public function __construct() {
add_action( 'wpcf7_mail_sent', array( $this, 'do_something' ) );
}
public function activate() {
// add_action( 'wpcf7_mail_sent', array( $this, 'do_something' ) );
// This hook would not be registered in activate() method.
}
public function do_something( $contact_form ) {
error_log( 'do_something was triggered.' );
// Header( 'Location: https://google.com' );
}
}
$my_cf7 = new MyCF7();
register_activation_hook( __FILE__, array( $my_cf7, 'activate' ) );
Теперь мой вопрос: Как я могу перенаправить наURL при отправке контактной формы?