Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Shelob9/25073dc0ecde270af2b97c0868655f3f to your computer and use it in GitHub Desktop.
Save Shelob9/25073dc0ecde270af2b97c0868655f3f to your computer and use it in GitHub Desktop.
<?php
//Change error message of AJAX submitted form.
add_filter( 'caldera_forms_render_notices', function( $notices ){
//Will NOT be set (during AJAX return) if there is no error
if( isset( $notices[ 'error' ], $notices[ 'error' ][ 'note' ] ) ){
$notices[ 'error' ][ 'note' ] = 'Form could not be submitted, please correct erorrs or give us a call.';
}
return $notices;
});
<?php
//Change error message of AJAX submitted form.
add_filter( 'caldera_forms_render_notices', function( $notices ){
//Will ONLY be set (during AJAX return) if there is no error
if( isset( $notices[ 'error' ], $notices[ 'error' ][ 'sucess' ] ) ){
$notices[ 'error' ][ 'sucess' ] = 'That was awesome!';
}
return $notices;
});
@SzaZo74
Copy link

SzaZo74 commented Sep 14, 2018

Hi,

This filter does not work at all.. Has no effect. Do you have any idea how I can change the success message dynamically?

Thanks,
Zoltan

@misfist
Copy link

misfist commented Oct 2, 2018

I believe, there are typos. This worked for me:

add_filter( 'caldera_forms_render_notices', function( $notices ) {
	if( isset( $notices[ 'success' ], $notices[ 'success' ][ 'note' ] ) ) {
		$notices[ 'success' ][ 'note' ] = 'That was awesome!';
	}
	return $notices;
});

Note: success (not "sucess") and the success text is accessed at $notices[ 'success' ][ 'note' ] ( "$notices[ 'error' ][ 'sucess' ]" )

Ref: https://calderaforms.com/doc/caldera_forms_render_notices/ should be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment