• Resolved Viviana

    (@vivicheruti)


    Hi,
    First of all I love this plugin. I’ve been looking for this kind of functionality for a while.
    I’ve been looking into the code and can’t find any way to hook a function to add some default display when the divi module is restricted.
    Is there any way to do this? So that I can add a login form instead, a text or a link for the user to subscribe or else in order to see the content?

    Thank u
    Viviana

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jonathan Horowitz

    (@jhorowitz)

    Hi @vivicheruti,

    Content Visibility for Divi Builder also comes equipped with a myriad of action and filter hooks. The documentation for them lives in the WordPress backend at /wp-admin/tools.php?page=module-extender-for-divi-builder-api-reference

    I believe what you are looking for is content_visibility_for_divi_builder_shortcode_$tag, which lets you filter the result of a module’s shortcode based on its shortcode tag. So, for example, if you wanted to do something when a contact form module’s output has been blanked out due to the visibility expression being false:

    
    add_filter( 'content_visibility_for_divi_builder_shortcode_et_pb_contact_form', function( $result, $atts, $content, $function_name, $et_pb_element, $et_pb_shortcode_callback ) {
      if ($result === '') {
        // This module has been blanked out; you may want to check this specific module is on the correct page, or has the correct id attribute, since this will fire for ALL instances of the module on your site
        $result = '<p>Some other html to show instead</p>';
      }
      return $result;
    }, 1338, 6 ); // 1338 or higher priority required to fire after content visibility for divi builder has evaluated the visibility expression
    
    Thread Starter Viviana

    (@vivicheruti)

    Thank u Jonathan for your super quick answer!
    That’s what I was looking for!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show Text / HTML when module not visible’ is closed to new replies.