• Hi,

    The filter, wpcf7_display_message, no longer supports html output. Is there a replacement that allows to add custom html?

    This article here is not the most flexible solution:
    https://contactform7.com/2016/01/27/html-is-not-allowed-in-messages/

    You would have to hide the default cf7 response output with css or hook add_filter(‘wpcf7_form_response_output’, ‘__return_empty_string’); or maybe leave the message blank in message settings..

    Then if you want custom messages for each status(sent, failed, spam, error) you would have to hide four strings with css or maybe use js to swap them out…as you can see all the work involved in figuring out how to properly display custom html messages increases.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, Luke, I am another Contact Form 7 user.

    I don’t think this is possible as the output of the filter will always be stripped of HTML tags, since the wp_strip_all_tags function is called with the output of the filter.

    Here is some code to provide additional context for what I’m talking about:

            /**
    	 * Filters a message.
    	 *
    	 * @param string $message Message to filter.
    	 * @param string $status Optional. Status. Default empty.
    	 * @return string Filtered message.
    	 */
    	public function filter_message( $message, $status = '' ) {
    		$message = wpcf7_mail_replace_tags( $message );
    		$message = apply_filters( 'wpcf7_display_message', $message, $status );
    		$message = wp_strip_all_tags( $message );
    
    		return $message;
    	}
    Thread Starter Lukasz

    (@wpfed)

    Thanks for the technical explanation @plantprogrammer,

    Looks like I’m out of luck!

    What other, more advanced/customizable form plugins do you use @plantprogrammer ?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Replacement for filter wpcf7_display_message’ is closed to new replies.