Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Evan Herman

    (@eherman24)

    Hi Habino,

    Unfortunately not in the current state. We hadn’t considered this bit of functionality, but would most certainly consider it in the next revision of the plugin.

    There may be a way to adjust the confirmation messages dependent on the form using the built in filters, but I haven’t attempted to do so.

    I’ll play around a bit and see if I can come up with some filter to customize the messages based on the form ID.

    I’ll report back here with some findings.

    Thanks,
    Evan

    Thread Starter habino

    (@habino)

    Thank you Evan, keep me posted on your findings!

    Plugin Author Evan Herman

    (@eherman24)

    Hey Habino,

    After poking around a bit, I believe I have found a fairly reasonable solution to your problem. We’ll want to use the yks_mc_content filter that is included with our plugin to target our confirmation message and display a message other than the one set in the settings page. You will also need to know the post ID of the page where the form resides.

    Using these two bits of information, we can customize the confirmation on a page by page basis.

    First:
    You’ll want to get the ID of the page where the form lives on, so we can target that specific page and form. You can easily find the page ID by going into the page (or post) edit screens and looking at the URL of the page. The ID of the post or page will look something similar to ?post=94, where 94 is the ID of the current page.

    Screenshot

    Second:
    You’ll want to place the following function into your themes (or child themes) function.php file, most likely at the bottom, and replace the post_id == '94' with the appropriate page or post ID for your site.

    function yks_mc_custom_confirmation_message($content) {
      global $post;
      $post_id = $post->ID;
    
      if ( $post_id == '94' ) {
         // alter the confirmation message on page or post with id 94
         $content = 'testing a custom confirmation on page 94!';
      } else {
         // alter the confirmation message on all other pages and posts
         $content = 'testing a custom confirmation on all other pages!';
      }
    
      // return our content
      return $content;
    }
    add_filter( 'yks_mc_content', 'yks_mc_custom_confirmation_message' );

    You’ll notice the conditionals added to the function. The first conditional checks if we are on the page or post with ID 94. If we are, the new confirmation message will be ‘testing a custom confirmation on page 94!’.

    If were not on page 94 (aka on all other pages and posts), the second confirmation message will be displayed ‘testing a custom confirmation on all other pages!’.

    You can add to or remove anything you’d like from this function. Lets say for example you only wanted to change the confirmation on the page or post with id 94. You could remove the second conditional so the function would now be:

    function yks_mc_custom_confirmation_message($content) {
      global $post;
      $post_id = $post->ID;
    
      if ( $post_id == '94' ) {
         // alter the confirmation message on page or post with id 94
         $content = 'testing a custom confirmation on page 94!';
      } 
    
      // return our content
      return $content;
    }
    add_filter( 'yks_mc_content', 'yks_mc_custom_confirmation_message' );

    That way, the custom confirmation message would be displayed on page or post with id 94, but the confirmation message you have set in the settings page will displayed in all other locations throughout the site.

    You can add as many conditionals as you would like in here, so if you were so inclined, you could have 100 or more separate confirmation messages displayed across your site.

    You can even go as far as adding conditionals for logged in users vs non-logged in etc.

    That should help push you in the right direction, but if you need any help getting things set up or explained differently I would be glad to do so!

    Thanks,
    Evan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple Custom Opt-In Messages’ is closed to new replies.