Resolved
Reported for: Contact Form 7 Multilingual 1.2.1
Resolved in: Contact Form 7 Multilingual 1.2.2
Overview of the issue
If you are using Contact Form 7 Multilingual plugin, you may encounter a PHP warning when viewing a page that includes a translated contact form. The warning states:
Warning: Undefined array key "title" in /path-to-website/wp-content/plugins/contact-form-7/includes/contact-form-functions.php on line 239
Workaround
Please, make sure of having a full backup of your site before proceeding.
- Open …/wp-content/plugins/contact-form-7-multilingual/classes/shortcodes.php file.
- Look for this piece of code:
1234
if
( !
$form
&& !
empty
(
$atts
[
'title'
] ) ) {
$form
= wpcf7_get_contact_form_by_title( trim(
$atts
[
'title'
] ) );
unset(
$atts
[
'title'
] );
}
- Comment out line 30:
1234
if
( !
$form
&& !
empty
(
$atts
[
'title'
] ) ) {
$form
= wpcf7_get_contact_form_by_title( trim(
$atts
[
'title'
] ) );
//unset( $atts['title'] );
}
Sorry WPML staff/support, but you know very well (or at least you should) that this is not a proper solution to the problem, as whenever we’ll update the plugin, the hack you are suggesting will be overwritten and well gone.
You should definitely correct your own plugin, or warn users that this hack will be overwritten by next updates.
For anyone reading this topic, there’s a safer and supported way to translate your forms (and all the messages stored in CF7), that does not need a plugin:
– as administrator, change your profile language into whatever language you want to translate the form into
– go to CF7 and add a new form: it’ll automatically be generated using the new language you have chosen above
– complete the form at your will (note that CF7 messages of this new form will use the new language)
– change back your profile language
you’ll now have 2 forms: the one in the original language and the one in new language.
Thank you for your insights, Max. We totally agree with you, this is just a temporary workaround and this problem should be solved in a future release.
We will keep this erratum updated.