• Resolved kent3205

    (@kent3205)


    Hi, I am very new to WordPress and only have a basic understanding so any help greatly appreciated. I have created a table in TablePress and have installed Row Filtering extension. The table has rows of data which apply to many users. The second column matches a users userid which is a 4 digit number. The row filter is working well when I use the command [table id=52 filter=”9999″ filter_columns=”2″ filter_full_cell_match=”true” /] where 9999 is the persons userid. My question is how do I obtain the userid for the particular user who is logged in and insert it into this code. I tried [table id=52 filter=get_current_user_id() filter_columns=”2″ filter_full_cell_match=”true” /] however no luck. Many thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    You could define a wrapper Shortcode, like this: https://ww.wp.xz.cn/support/topic/tablepress-show-only-table-rows-that-contain-current-logged-in-user-id/#post-11261133

    Regards,
    Tobias

    Thread Starter kent3205

    (@kent3205)

    Hi Tobias

    Tank you very much for our response. Sorry I didn’t manage to find that in my searching. The plugin and extension are great and work really well.

    I am using the Shortcode and it has worked well. I have loaded it using the Snippets plugin. (I am not confident enough to edit the .php file.)

    The only strange things is that when I have the snippet active and I try to edit the page with the table, I get the message “There has been a critical error on your website. Please check your site admin email inbox for instructions.” When I turn off the snippet I can see the page fine.

    It doesn’t seem to impact the operation of the site though.

    Again many thanks
    Kent

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    I could imagine that this is related to scoping issues, i.e. whether the request is in the admin or frontend. You could maybe put the entire code in an extra check:

    if ( ! is_admin() ) {
      // Current code goes here.
    }

    Regards,
    Tobias

    Thread Starter kent3205

    (@kent3205)

    Thanks Tobias

    You really know your WordPress! Reading your code made me realise in snippet I have the option selected to run code everywhere vs just front end. Changing that I think effectively did the same thing.

    Again many thanks

    Kent

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    yes, that’s probably the same thing 🙂 Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

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

The topic ‘Tablepress row filter using userid’ is closed to new replies.