Okay
  Public Ticket #3343556
%CURRENT_USER_ID% in column with foreign key
Closed

Comments

  • Fietsmaatjes started the conversation

    Hi,

    For a new table I want to add a field with the creator (user) of a record.

    I've added a field based on an other table with specific users (foreign key). The field-configuration in the edit-tab is single value selectbox.

    What I would like, is to configure a pre-defined value; %CURRENT_USER_ID%. Alas, the only thing I can do is pick one of the users and put that as predefined value.

    Is it somehow possible to use %CURRENT_USER_ID%?

  •  1,849
    Miloš replied

    Hi, Fietsmaatjes.

    I am sorry to disappoint you, but with our current plugin capabilities, it is not possible to achieve that with a Foreign Key Column.

    As you said, when we use a foreign key Column - it is only possible to choose Single value selectbox for Editing;

    thus it is not possible to use the 'Current_user_ID' placeholder there.

    We can only add the Current_User_ID placeholder if the Editor Type is something like a "One Line Edit", or "Multi-Line Edit".

    9761882594.png
    3889365379.png

    -

    For example,  i just did some testing with my SQL Tables.

    If i got these two tables from SQL Databse ,  "customers" and 'employees";

    in the Customers, each customer has its unique ID,  same goes for the Employees Table.

    Then if i wish to make a new Table - for this example i just make a simple Manual table,

    and if i make a Foreign Key Relation for Customers,

    i set the "Store Value" as the Customer ID column,

    and display value to Customer First Name;

    Then if i manually input value of Customer ID - it will automatically pull the right Customer Name.

    4537501943.png
    5295050137.png
    6324283201.png

    For example, this Customer First name Sven, is Customer ID 1 - so first i set the column as Integer, and save it - so it gets stored in the Database as Integer;

    then switch it to String, set Foreign Key Relation,

    and if i input 1 - it pulls the correct Customer Name.

    1354547098.png

    -

    If you wish to see the built-in option to set predefined Editor Type as "One Line Edit" or "Multi Line Edit",

    for Foreign Key Column Editing, you can make a suggestion for our developers,

    but i can't say an ETA if or when that might be possible.

    Please feel free to search on our suggestions page

     to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there,  and as more people vote, the feature will move higher on the priority list.

    You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;

    and our newsletter, so you're informed about new features, bug fixes, freebies, etc.

    -

    For the time being, the only built-in way that we have to auto-populate the user ID field,

    can be either as shown with another Editor Type,

    or you can also try our feature, where users can see and edit only their own data/ associated to their user ID;

    but i see that this is not ideal for your use-case.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    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