• Resolved lacoste89

    (@lacoste89)


    For anyone who is currently looking for a way to use shortcodes in the global message for limited access:

    remove_filter('the_content', array(UM()->access(), 'filter_restricted_post_content'), 999999, 1);
    
    add_filter('the_content', function($content) {
    
        if (current_user_can('administrator')) {
    
            return $content;
    
        }
    
        $id = get_the_ID();
    
        if (!$id || is_admin()){
    
            return $content;
    
        }
    
        $ignore = apply_filters('um_ignore_restricted_content', false, $id);
    
        if ($ignore) {
    
            return $content;
    
        }
    
        if (UM()->access()->is_restricted($id)) {
    
            $restriction = UM()->access()->get_post_privacy_settings($id);
    
            if (!isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message']) {
    
                $content = stripslashes( UM()->options()->get('restricted_access_message'));
    
            } elseif ('1' == $restriction['_um_restrict_by_custom_message']) {
    
                $content = ! empty($restriction['_um_restrict_custom_message']) ? stripslashes($restriction['_um_restrict_custom_message']) : '';
    
            }
    
            return apply_shortcodes($content);
    
        }
    
        return $content;
    
    }, 999999, 1);
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Solution for Shortcodes in Custom Restrict Content message Version > 2.8.x’ is closed to new replies.