• Resolved Luis Carlos Pando

    (@luiscarlospando)


    Is there any way to add an icon next to the post title indicating that the post is protected?

    I’m using Font Awesome to display extra icons in my theme, and I would like to display a lock icon only when a post is protected.

    I tried to add the icon’s HTML code to the WYSIWYG editor in where you edit the “Messages for logged-out users” but apparently it doesn’t render HTML code.

    Is there any why the plugin add a class to the protected posts or some way I could achieve this?

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    In order to display a Font Awesome Lock Icon when a post/page is restricted you will need to use some custom code:

    1. Create an empty plugin like this: https://gist.github.com/sareiodata/76f701e01db6685829db

    2. Add the following code to the end of it:

    /*
     * Filter to display a Locked Font Awesome Icon next to the Title of a Restricted Post/Page
     */
    
    add_filter('the_title', 'pmsc_add_icon_next_to_restricted_post', 10, 2);
    
    function pmsc_add_icon_next_to_restricted_post($post_title, $post_id) {
        if (is_admin()) {
            return '';
        }
        if (pms_is_post_restricted($post_id)) {
            return '<i class="fa fa-lock" aria-hidden="true"></i>' . ' ' . $post_title;
        }
        return $post_title;
    }

    3. Install this plugin via FTP (copy it inside wp-content/plugins) or create a zip archive with it and install it via the WordPress plugin upload functionality

    Let me know if it works.

    Best regards,

    Thread Starter Luis Carlos Pando

    (@luiscarlospando)

    Hey Teodor!

    It worked perfectly, that’s exactly what I wanted to do. Thank you so much for your support!

    Greetings,
    Luis Carlos Pando

    Hi Teodor

    Apologies for the strange request but I’ve been wracking my brains trying to achieve this exact feature on my membership website. I’m unfortunately unable to use your fantastic membership plugin as I am tied in to using LearnDash (+several LMS plugins) which only work with Woocommerce. My question is whether you’d be interested in writing the code that would make this feature work for my site? I’d be happy to pay for this obviously.

    Fingers crossed!

    Best wishes
    Jon

    Hi Jon,

    Thank you for reaching out to us. I understand that you are not using PMS for your membership website but you are using a membership plugin. Is this correct? Which plugin is managing the subscriptions and the content restriction feature?

    Did you contacted the developers of that plugin regarding your request? As you can see you need to filter the_title and to add the condition. I hope you understand that I don’t know your whole setup in order to make the custom code and your question is not related with PMS. Also this support thread is marked as resolved so my suggestion, for the future, would be to open a new support thread.

    Best regards,

    Thanks so much for your reply Teodor – I’ve created a new support thread as you suggested.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Displaying a lock icon only on restricted content’ is closed to new replies.