Okay
  Public Ticket #2596347
Buddypress compatible
Closed

Comments

  • Jota started the conversation

    Hi, I´m trying to make a table with all the users on my web, but I want it to show buddypress xprofile fields.

    Please, how could I grab the data on xprofile fields to add it to my table?

    Thanks in advance!

  • Jota replied

    Hi again!

    I´ve write an sql query that shows 2 fields from buddypress, but when I try to edit the values of the table in frontend, I have this error: Close Error! There was an error trying to update the row! Error: Unknown column 'telefono' in 'field list'

    What´s wrong????

    Here is the mysql query:

    SELECT distinct wp_bp_xprofile_data.user_id, telefono.value AS 'telefono', nombre.value AS 'nombre'
    FROM wp_bp_xprofile_data
    LEFT JOIN wp_bp_xprofile_data AS telefono ON wp_bp_xprofile_data.user_id = telefono.user_id
    AND telefono.field_id = '61'
    LEFT JOIN wp_bp_xprofile_data AS nombre ON wp_bp_xprofile_data.user_id = nombre.user_id
    AND nombre.field_id = '1'


    Thanks again!


  •  2,572
    Aleksandar replied

    Hello Jota

    Thank you for your purchase.

    Unfortunately, since wpDataTables is not a database management plugin, it cannot work as good as phpMyAdmin or other database management tools.

    The issue is with the query - since you have a slightly complex query, with JOINs, editing will not work, and there's a possibility filtering and sorting won't work also.

    Unfortunately, the only workaround for filters and sorting is to create a MySQL view with this query, and then create a wpDataTable using that view, like SELECT * FROM view.

    However, that will not make the table editable, and I'm afraid since you'll need to pull the data from multiple tables you will not be able to do this.

    Like mentioned in our documentation:

    Only one MySQL table can be edited at a time. Queries from multiple tables with joins cannot be used as an editable feature, since SQL UPDATE and INSERT statements are generated automatically, and there currently is no way to update multiple tables – but this problem is being investigated and pursued

    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

  • Jota replied

    Thanks, Aleksandar.

    And what about a query like this? Should it works?

    SELECT wp_bp_xprofile_data.value AS telefono FROM wp_bp_xprofile_data WHERE wp_bp_xprofile_data.field_id = 61
    UNION
    SELECT wp_bp_xprofile_data.value AS nombre FROM wp_bp_xprofile_data WHERE wp_bp_xprofile_data.field_id = 1

    Data is grabbed from a unique table (wp_bp_xprofile_data), so I think it would be fine.

    However, if I use this query, the table only show the first row "telefono"


    Or, if you prefer and forgetting buddypress plugin, I´d like to grab wordpress users metadata and edit from frontend. Is this not possible either?

  •  2,572
    Aleksandar replied

    Hi again Jota

    If you're using UNION, make sure to add UNION ALL at the end of the query, so instead of:

    SELECT wp_bp_xprofile_data.value AS telefono FROM wp_bp_xprofile_data 
    WHERE wp_bp_xprofile_data.field_id = 61
    UNION
    SELECT wp_bp_xprofile_data.value AS nombre FROM wp_bp_xprofile_data 
    WHERE wp_bp_xprofile_data.field_id = 1

    Use this:

    SELECT wp_bp_xprofile_data.value AS telefono FROM wp_bp_xprofile_data 
    WHERE wp_bp_xprofile_data.field_id = 61
    UNION
    SELECT wp_bp_xprofile_data.value AS nombre FROM wp_bp_xprofile_data 
    WHERE wp_bp_xprofile_data.field_id = 1
    UNION ALL

    That may work. However, to edit the table you will need an ID column which will be the column for editing.

    You can pull data from metadata, but I'm not sure you'll be able to edit it. 

    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