Customizing Confirmation Messages
This topic contains 4 replies, has 3 voices, and was last updated by Samantha 5 years, 7 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: snippet
-
AuthorPosts
-
March 16, 2020 at 8:53 pm #535472
Hi there,
I have multiple CPT and I need the confirmation message to say something different depending on which CPT was submitted.
This is the text that shows:
“Post received, your listing is now live and can be viewed here.”I need to be able to change that depending on the CPT and add a button on that page so I can direct them where I want the user to go next.
How can I adjust the confirmation depending on the CPT submitted?
Thanks!
March 16, 2020 at 8:53 pm #535474This reply has been marked as private.March 16, 2020 at 10:51 pm #535477I am not sure that is possible but let’s ask the developers too.
ThanksMarch 17, 2020 at 4:21 am #535487Hello Misty,
Try following PHP snippet to customize post save confirmation messages.
/** * Customize save post messages. */ function gd_snippet_200317_save_post_message( $message, $post_data ) { if ( empty( $post_data['post_parent'] ) && $post_data['post_status'] != 'publish' ) { $post = new stdClass(); $post->ID = $post_data['ID']; $link = GeoDir_Post_Data::get_preview_link( $post ); } else { $link = get_permalink( $post_data['ID'] ); } $post_type = get_post_type( $post_data['ID'] ); if ( ! empty( $post_data['post_parent'] ) ) { // Update post if ( $post_data['post_status'] == 'publish' ) { // Published if ( $post_type == 'gd_apartments' ) { $message = wp_sprintf( __( 'Apartment update received, your changes are now live and can be viewed %shere%s.', 'geodirectory' ), "<a href='" . $link . "'>", "</a>" ); } elseif ( $post_type == 'gd_business' ) { $message = wp_sprintf( __( 'Business update received, your changes are now live and can be viewed %shere%s.', 'geodirectory' ), "<a href='" . $link . "'>", "</a>" ); } } else { // Pending if ( $post_type == 'gd_apartments' ) { $message = __( 'Apartment update received, your changes may need to be reviewed before going live.', 'geodirectory' ); } elseif ( $post_type == 'gd_business' ) { $message = __( 'Business update received, your changes may need to be reviewed before going live.', 'geodirectory' ); } } } else { // New post if ( $post_data['post_status'] == 'publish' ) { // Published if ( $post_type == 'gd_apartments' ) { $message = wp_sprintf( __( 'Apartment listing received, your apartment listing is now live and can be viewed %shere%s.', 'geodirectory' ), "<a href='" . $link . "'>", "</a>" ); } elseif ( $post_type == 'gd_business' ) { $message = wp_sprintf( __( 'Business listing received, your business listing is now live and can be viewed %shere%s.', 'geodirectory' ), "<a href='" . $link . "'>", "</a>" ); } } else { // Pending if ( $post_type == 'gd_apartments' ) { $message = wp_sprintf( __( 'Apartment listing received, your apartment listing may need to be reviewed before going live, you can preview it %shere%s.', 'geodirectory' ), "<a href='" . $link . "'>", "</a>" ); } elseif ( $post_type == 'gd_business' ) { $message = wp_sprintf( __( 'Business listing received, your business listing may need to be reviewed before going live, you can preview it %shere%s.', 'geodirectory' ), "<a href='" . $link . "'>", "</a>" ); } } } return $message; } add_filter( 'geodir_ajax_save_post_message', 'gd_snippet_200317_save_post_message', 20, 2 );Regards,
KiranMarch 18, 2020 at 7:12 pm #535659Yes, that works perfectly. Thank you!
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket