Okay
  Public Ticket #2523355
Data is not visible to logged in user
Closed

Comments

  • Lance Redgrave started the conversation

    I've created a table that include both an Post Author Column and a wp_user.ID column. 

    On the "Editing" tab, I've set the "User ID Column" to my  wp_user.ID column. 

    When I login with a user that has data, no data is visible in the table?

  • Lance Redgrave replied

    This is the query I am using:


    SELECT posts_deliverable.ID AS deliverable_ID,
           posts_deliverable.post_title AS deliverable_post_title,
           CONCAT('<a href="',posts_deliverable.guid,'">',posts_deliverable.post_title,'</a>') AS deliverable_title_with_link_to_post,
           posts_deliverable.post_content AS deliverable_post_content,
           posts_deliverable.post_status AS deliverable_post_status,
           posts_deliverable_author.display_name AS deliverable_post_author,
           posts_deliverable_author.ID AS deliverable_post_user_ID,
           deliverable_taxonomy_category_tbl.name AS deliverable_taxonomy_category
    FROM wp_posts AS posts_deliverable
      INNER JOIN wp_users AS posts_deliverable_author
         ON posts_deliverable_author.ID = posts_deliverable.post_author
      INNER JOIN (SELECT name, object_id as id FROM wp_terms AS deliverable_taxonomy_category_tbl_terms INNER JOIN wp_term_taxonomy AS deliverable_taxonomy_category_tbl_termtaxonomy ON deliverable_taxonomy_category_tbl_termtaxonomy.term_id = deliverable_taxonomy_category_tbl_terms.term_id  AND deliverable_taxonomy_category_tbl_termtaxonomy.taxonomy = 'category' INNER JOIN wp_term_relationships AS rel_deliverable_taxonomy_category_tbl  ON deliverable_taxonomy_category_tbl_termtaxonomy.term_taxonomy_id = rel_deliverable_taxonomy_category_tbl.term_taxonomy_id) AS deliverable_taxonomy_category_tbl
         ON deliverable_taxonomy_category_tbl.ID = posts_deliverable.id 
    WHERE 1=1 


  •  2,572
    Aleksandar replied

    Hello Lance

    I'm sorry, but I don't see wp_user.ID column in your query (you mean wp_users table, right?).

    The column needs to be included in the query in order to get it to work.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Lance Redgrave replied

    Yes sorry I meant wp_users.

    The query includes   INNER JOIN wp_users AS posts_deliverable_author

    Is this not enough?



  •  2,572
    Aleksandar replied

    If you see the column in the drop-down, it should be enough.

    However, using a query like this may cause some issues.

    Please prepare a MySQL view (a stored query), which will return the data that you need, call it e.g. “view1” and then build a wpDataTable based on a simple query like “SELECT * FROM view1″.

    When working with the server-side processing feature, please note:

    • Please do not use “LIMIT” in the SELECT statement. wpDataTables adds it automatically and it will be overridden.
    • Please do not use “ORDER BY” in the SELECT statement. wpDataTables has its own sorting engine so it makes no sense to use MySQL’s sorting, since it will be overridden. Also, server-side processing feature adds this part of statement automatically when users trigger the sorting on the front-end, and having it in initial statement may cause the table to crash.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables