Support » Plugin: Members » shortcode content displaying even when permission to user role blocked

  • Resolved jshrek

    (@jshrek)


    Hi

    I am creating my own plugin that uses a shortcode.

    When I put my shortcode onto a page, and then set content permissions to only allow administrators, the shortcode content is still displayed above the message “Sorry, but you do not have permission to view this content” for non-administrators.

    TO REPRODUCE:

    Create a new page and place the shortcode [TEST_SHORTCODE_DISPLAY] on it and publish.

    Then create a new plugin with the following code:

    function test_the_shortcode_display() {
        echo 'YES TEST!!!';
    }
    function test_register_shortcodes() {
        add_shortcode('TEST_SHORTCODE_DISPLAY', test_the_shortcode_display );
    }
    add_action( 'init', 'test_register_shortcodes');

    Should I be checking for your plugins content permissions before displaying the shortcode? Or do I need to add_action in a different hook instead of init?

    • This topic was modified 1 year, 2 months ago by  jshrek.
    • This topic was modified 1 year, 2 months ago by  jshrek.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘shortcode content displaying even when permission to user role blocked’ is closed to new replies.