Okay
  Public Ticket #1860974
User Id / editing rights
Closed

Comments

  • JackNewcastle started the conversation

    Hi,

    I watched the video on restricting editing for users, but it doesn't illustrate what to do in a case where you're pulling information from an external database.  For example, I have a unique user id in my MySQL db called Calendar ID. I've also entered this number into the WP user profile, so that every user has a unique Calendar ID that matches between the WP Profile and the external db. I'd like wpDataTable to only show the user the rows that only contain their unique Calendar ID.

    Therefore, on the editing tab, I select Calendar ID as the User ID Column, but, as I suspected, no rows show up when I am logged in as that user, and I'm assuming it's because WpDataTables is only pulling the primary WP user ID for a match. In short, is there a way to force WpDatable to match the MySQL Calendar ID to the WP Calendar ID?  

    Thanks and kind regards,

    Jack

  •  2,572
    Aleksandar replied

    Hello Jack.

    I apologize for the late response.

    If I understood you correctly, you managed to add the unique user id, but when you click on "Add new" or "Edit" modal, there are no values displayed one of the drop-downs?

    Are you using a foreign key? If that is true, there is a known issue that will be fixed with the next update. You can open the Editor, under Plugins, select wpDataTables from the drop-down in the top right, and select source/class.wpdatacolumn.php file. Please take a look at the attachment, and comment the lines of code like shown in the screenshot. That'll allow the users to view all possible values defined by the foreign key.

    We apologize for any inconvenience this may have caused.

    If this is not the case, and you created a table like explained in our documentation, then the user id column should be set as AUTO_INCREMENT and be a unique column in PHPMyAdmin, and if it is set like that, it should work correctly.

    Please let me know.

    Best regards.

    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

  • Adrien replied

    Also with columns that take values from foreign tables, when user in front edit existing row and don't change the values from those columns / foreign tables, it get saves as string in database and not integer anymore... So the row cannot be seen anymore in front.

    Can this issue get fixed too please?

  • JackNewcastle replied

    Thanks for the reply, Aleksandar. Perhaps I didn't make myself as clear as I could have, so I've attached a screen cap. I have a problem in that I'm pulling initially pulling data from third-party scheduling software, whose database doesn't have my users attached to their WordPress ID. However, I can use their Google Calendar IDs as a Primary Key identifier. This key I enter into each users WP profile as part of the database. So, what I would like to know is if I can instruct WPDataTable to use THAT field as a WP Identifier rather than the User ID that WP automatically assigns. 

    So, looking at the screen cap, we can see that I'm able to select the Calendar ID from my MYSQL database but it seems there's no way to link this key to the User Profile Calendar IDs that I create.  Perhaps that's just not possible.

  •  2,572
    Aleksandar replied

    Hello again Jack.

    You can try creating a query that'll return the data from that external db, which has the Calendar ID, and to join it with the WP table that saved that ID in WP user profile. We didn't have such case so far, but you can try it. Please note that writing queries doesn't fall under support for the plugin, but something like that should work.

    As for foreign keys - that is not a bug, because the foreign key column is string by default, which is why it is saved like string in database.

    Best regards.

    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

  • JackNewcastle replied

    I managed to get something worked out, but I'm a bit confused about joining WPDatatables. For example, I set up a WP Datatable that pulls all my info from a MYSQLdb by using the Generate a Query from an MYSQl Db. It works fine. Now I want to create a manual WPD table that has a few columns but also pulls a few of the columns from the query I created. So, I create the columns and add the foreign keys from the the table query that pulls from MySQL. The problem is that no data appears in the columns. I'm attaching a screencap of my foreign key settings. Do I have something wrong?

  •  2,572
    Aleksandar replied

    Hi Jack.

    I'd like to look at your website, if at all possible?

    Can you, please provide me a temporary WP-admin login for your site where this happens, so we could log in and take a look ‘from the inside’ as that’s the most efficient way to see and resolve the issue. We do not interfere with any data or anything else except for the plugin (in case that’s a production version of the site), and of course we do not provide login data to third party. You can write credentials here just check Private Reply so nobody can see them except us.

    Best regards.

    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

  •   JackNewcastle replied privately
  •  2,572
    Aleksandar replied

    Hello again Jack.

    As you can see, I created a new table to try and get the data you were hoping for. The thing is that - if you want three columns to be pulled using a foreign key, you need two source tables (in your case), that need to have a unique auto_increment integer value assigned.

    For example, you'd need to have a Student table, where each row will be a new student, and each student has to have a unique ID; to use "Last Name" and "First Name" columns in a new manual table that has Foreign key relations, there has to be an ID column that matches the unique IDs for each student. Let's say you have a source Student table:

    6255825914.png

    When you create a new manual table, it has to look like this:

    4843503125.png

    So, row for ID: 1 - under Last name - you need to assign a foreign key which will Choose a source wpDataTable from the previous table, Store value will be "Student ID" for (let's say) Jane Doe - 2, and display value will be "Student Last".

    Then, row for ID: 1 - under First name - you need to assign a foreign key which will Choose a source wpDataTable from the previous table, Store value will be "Student ID" for (let's say) Jane Doe - 2, and display value will be "Student First".

    Same goes for the already existing "Scheduled_apointments" table. But note that "Educator_WP_ID" has to have the same ID as the student in question. So if you have Educator_WP_ID set to 3 and Student ID set to 2, it's not going to work.

    Again, they all must have unique auto_increment column.

    Also, please avoid using " ` " when generating queries. That may cause an issue with search, generation and filtering of the table. So, for [wpdatatable id=6] query can look like this:

    SELECT Appointment_ID,
           Student_Last,
           Student_First,
           Student_Email,
           Student_Time_Zone,
           Student_Label,
           Notes,
           Educator_Full_Name,
           Educator_WP_ID,
           Educator_Appointment_Time,
           Appointment_Type,
           Zoom_Meeting_Room,
           Canceled
    FROM   Scheduled_Appointments
    

    May I ask if you followed the tutorial in our documentation. You can recreate the same table shown there, and it may provide a clearer picture of what needs to be done in order for foreign keys to work normally.

    Please try this and let me know if it works.

    Best regards.

    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