Okay
  Public Ticket #2713981
Limit to edito your own data only and foreign keys
Closed

Comments

  • Nacho started the conversation

    I have a table (sales) with a foreign key field (clients) and when I try to make a new entry from the back end from the Administrator It works perfectly but in the front end It does not work for users and even for the Administrator. It does not have any element in the dropdownlist for selecting the client.

    Is does like this, or what I have to do?

    I would like to buy Master detail and the reports but I need to solve this issue.

    Other thing, I have been cheking documentation and the currency type is not available in my plugin. Why? 


  •  2,521
    Aleksandar replied

    Hello Nacho

    Thank you for your purchase.

    Do you have "Users see and edit only own data" feature enabled in any of these tables? If you do, each foreign key value needs to have the user ID assigned to it. Meaning, if you want to allow adding new clients (foreign key value) in a table where users can see and edit only own data, each client needs to be repeated in the remote table per user ID.

    So, if you have 10 users, you need to add "Mike" (for example) in 10 rows, and assign each row with the ID of your existing users.

    I'm not sure what you mean by currency type - can you please explain that?

    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

  • Nacho replied

    I think all is right but It does not work.

    5286863859.png

    This is the configuration for editing for the table sales - Ventas-.

    This are the columns of the table:

    7501405970.png

    This is the configuration of the column with the foreign key to the table Clients:

    9423079891.png



    This are the columns of Clients table:

    5873682267.png

    I don't know what is wrong but It does not work?


  •  2,521
    Aleksandar replied

    Hi again Nacho

    wdt_ID is a unique auto-increment column, automatically generated in manual tables. Each new row receives a new ID, so when you configure the foreign key to pull the data from wdt_ID instead of userid column - it's not going to work.

    Change the foreign key, and set the store value to be userid column, and it should work fine.

    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

  • Nacho replied

    Hello Aleksander,

    The columns with a foreign key are not working in my wordpress.

    I think all is correct, because the foreign key must pull the data from the ID of the other table. If I change It with userid It does not work and only appears in the result the row with the ID that has the same number as the userID.

    Sorry, I don't know what to do, and I need to solve this problem in order to understand what to do. I like the plugin and I need It. 


    So please can you connect and check what is happening. Enter to my website please and check It.

    Please can you quote me this work, or tell me the price per hour, whatever your prefer, but I need to understand how to do the dropdown combos with a foreign key.

    I am using this plugins:

    -the Paid Memberships Pro , -the Polylang, -Limit Login Attempts Reloaded, -Gutenberg, -Dissable Comments, A3 Lazy load and -Antispam Bee

    I don't know If is compatible or perhaps there is a problem with one of this plugins that is making foreign key does not work.

    PHP version is 7.0.33 that says needs actualization and MySql version is not the last one and wordpress is telling me to connect with the hosting (IONOS) to ask them for actualization to version 5.6 o higger. Can It be this?


    My phone number is 696428598. Or Skype, Teams or whatever you prefer, or connect to my computer, I don't mind. Tell me how to solve this issue and how to pay It. 

    Thank you very much in advance.


  • Nacho replied

    Hi Aleksandar again,

    Other thing I don't understand the foreign key column type of data.

    I have to select string as the type of data for the column in order to be able to select foreign key, but the column in the other table must be an integer and in this table too. Perhaps this is the problem?.

  •  2,521
    Aleksandar replied

    Hi again Nacho

    At the moment, we don't have time to accept any custom work, so there'll be no quote for the service (as we're not able to offer customization services).

    Please check out the foreign key documentation, and follow it to duplicate the example from there locally. It will give you a good idea of what it does.

    In short:

    1. You have a table which contains the values. Each row needs to have the ID associated to the value. So, you can use wdt_ID, but if you're using Users see and edit only own data feature, that won't work because the user's ID is a unique ID stored in wp_users database table, while wdt_ID is an automatically generated auto-increment column; meaning each new row consists of the new ID. If your user's ID is 5, foreign key will only be able to pull the data from row where wdt_ID = 5.

    2. This original table needs to have 2 columns - store value (ID) and display column (the value that's going to be displayed in the second table).

    3. In the second table, create an Integer column. It needs to initially be integer, because the store value from the original table is also an integer, and the database relations are saved as integers. Then, you go to column settings/data and change its type to "String". After that you configure the foreign key in step 4.

    4. Choose the source table (the first table, which contains the values); then select the store column (ID) and the display column (value). You can also enable editing for this column in table 2, so the editor input type (also in column settings) is set to "Select-box".

    5. With that configured, you will be able to choose the data in that column from a select-box that will pull the values from the first table.

    Again, if one table is set to use "Users see and edit only own data" feature, they will only be able to see rows and values associated to the ID of the user they are currently logged into WordPress with.

    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