• Resolved rkahana

    (@rkahana)


    Hello,

    Plugin works well but when trying to use it to control content within an HTML table weird things happen.

    I’m trying to do the following:

    <table class="input-parameters">
    <tbody>
    <tr>
    <td>Resource</td>
    <td>Description</td>
    </tr>
    [eyesonly logged="in" pp_group="12"]
    <tr>
    <td><b><a some link>some link</a></b></td>
    <td>blah blah blah</td>
    </tr>
    [/eyesonly]
    </tbody>
    </table>

    When switching between the text and visual editors, the shortcode gets taken out of the table and placed before the table itself resulting in:

    [eyesonly logged="in" pp_group="12"][/eyesonly]
    <table class="input-parameters">

    Any ideas?

    https://ww.wp.xz.cn/plugins/eyes-only-user-access-shortcode/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author thomstark

    (@thomstark)

    Hi. First of all, you don’t need “logged=in” if you’re using pp_group=”12″ or the level=”whatever” attributes. Only those specified in pp_group= or level= will be able to see the content, so logged out users are excluded as well. Just for the record.

    HTML doesn’t allow you to put code in between table-row tags like that, which is why WordPress is moving the eyesonly shortcode out of the table. It knows it doesn’t belong where you’re putting it. Here’s what you can do. Put the shortcodes inside the TD tags and do one shortcode to show to your PP group, and one shortcode to hide content from that same PP group:

    <table>
    <tr>
    <td>[eyesonly pp_group="12"]Content for Group 12[/eyesonly][eyesonly pp_group="12" hide="yes"]Content for everyone else.[/eyesonly]</td>
    <td>[eyesonly pp_group="12"]Content for Group 12[/eyesonly][eyesonly pp_group="12" hide="yes"]Content for everyone else.[/eyesonly]</td>
    </tr>
    </table>

    That will work fine.

    Thread Starter rkahana

    (@rkahana)

    Thanks for the prompt reply!

    I understand your solution but I’m trying to avoid presenting empty rows/cells in a table with multiple rows.

    If I have a table with 20 potential rows and wish to display only rows 5 10 and 13 to a certain group, I would preferably like to present a table with only 3 rows instead of a 20 row table with 17 redacted rows.

    Do you have any creative workaround for that?

    Thanks again for the quick engagement.

    Plugin Author thomstark

    (@thomstark)

    Well, depending on how sensitive the info is in the table-row that you’re restricting, CSS may or may not be a solution for you. But you can apply two classes to the TR element and then follow up your HTML with some inline styles, where one of the two classes is defined inside eyesonly tags, like this:

    <table>
    <tbody>
    <tr class="hide-default ppgroup-twelve-show">
    <td>Stuff only for PP Group 12</td>
    </tr>
    
    <tr>
    <td>Stuff for everyone</td>
    </tr>
    </tbody>
    </table>
    
    <style><!--
    .hide-default {display:none;}
    [eyesonly pp_group="12"]
    .ppgroup-twelve-show {display:inherit!important;}
    [/eyesonly]
    --></style>
    Thread Starter rkahana

    (@rkahana)

    Nice solution!

    Thanks again.

    Plugin Author thomstark

    (@thomstark)

    Alternatively, you can just create two completely different tables, and hide one of them from pp_group 12 and show the other one only to pp_group 12. It’s a bit clunkier, but it’s really just copy/paste work.

    Plugin Author thomstark

    (@thomstark)

    No worries. Let me know if you need any further help.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘shortcode usage in HTML tables’ is closed to new replies.