Customizing Confirmation Messages

This topic contains 4 replies, has 3 voices, and was last updated by  Samantha 2 years, 6 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #535472

    Samantha
    Full Member
    Post count: 33

    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!

    #535474

    Samantha
    Full Member
    Post count: 33
    This reply has been marked as private.
    #535477

    Guust
    Moderator
    Post count: 29970

    I am not sure that is possible but let’s ask the developers too.
    Thanks

    #535487

    Kiran
    Moderator
    Post count: 7069

    Hello 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,
    Kiran

    #535659

    Samantha
    Full Member
    Post count: 33

    Yes, that works perfectly. Thank you!

Viewing 5 posts - 1 through 5 (of 5 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket