• Hi,

    I’m trying to use WPDA to manage course enrolment on my school. We use a CRM inside WordPress to manage contacts. WPDA lets us extend that CRM to manage courses, classes and other student data.

    I need a way to access a single student record, to edit enrolment details. Instead of having a table with students in rows, I need that edit screen just for one student (based on an ID field in the table), to edit the data.

    Is there an easy way to do it? A shortcode with specific parameters using a variable?

    Thanks.

    álvaro

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Alvaro,

    Good to hear from you again! ??

    >>> I need a way to access a single student record, to edit enrolment details. Instead of having a table with students in rows, I need that edit screen just for one student (based on an ID field in the table), to edit the data.

    Where do you run your code?
    (1) In the back-end
    (2) On a web page with shortcode wpdadiehard
    (3) On a web page with Data Forms

    Thanks,
    Peter

    Thread Starter Alvaro Gois dos Santos

    (@alvarogois)

    Hi Peter,

    Yes, still strugling with this project.

    For this specific use I would run it in the back-end.

    But can use it both ways, restricting access to pages based on user roles for example.

    Thanks

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Alvaro,

    The back-end is the safest and easiest way!

    To edit a specific student with id = 123 you can use this URL:
    /wp-admin/admin.php?page=wpda&action=edit&table_name=student&id=123

    This only works in the back-end and the user has sufficient privileges to edit the table.

    Hope this helps,
    Peter

    Thread Starter Alvaro Gois dos Santos

    (@alvarogois)

    Awesome. I’m going to try that and give you feedback.

    Thanks.

    Thread Starter Alvaro Gois dos Santos

    (@alvarogois)

    Hi Peter,

    Great. I can see it working. What if I want to use a php function or shortcode to show the same record table in a backend page, is it possible?

    Similar to this SAS demo, but in edit mode and inside one of my CRM backend pages. Is it achievable?

    Thanks.

    álvaro

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Alvaro,

    >>> What if I want to use a php function or shortcode to show the same record table in a backend page, is it possible?

    That depends on your CRM app. Is it a WordPress plugin? Are there any hooks or filters? Or other ways to inject your own code?

    Please let me know,
    Peter

    Thread Starter Alvaro Gois dos Santos

    (@alvarogois)

    Hi Peter,

    Yes, I’m using Jetpack CRM (used to be called Zero BS CRM).

    It has a tabs area in the contact record view where we can add a custom tab with content, using an available filter (the two buttons tab in the example is a custom tab, where I add links to frontend pages with URL query string parameters, based on the contact ID field).

    We can use variables like $id (the contact ID field) for parameters in a query string, or a shortcode. If we have a shortcode for a frontend page, maybe we can use it in a custom tab like this.

    The advantage here would be to have those extra WPDA tables with contact data right there in the contact view, without having to go to a different page in the backend.

    Thanks.

    álvaro

    PS: BTW, one of those buttons in the custom tab links to an application form, with all the contact data, for printing. We talked about it last year and this is the way I managed to get it working. Not ideal but it works.

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Alvaro,

    I don’t know Jetpack CRM, but you might be able to add a WP Data Access list table and data entry form to a tab with that filter. You will need to call some WP Data Access classes directly from your own PHP code. Here is some example code:
    https://wpdataaccess.com/2020/04/08/how-to-use-wp-data-access-classes-in-your-own-php-code/

    Maybe you can use it as a starting point and let me know if this is what you are looking and how I can help.

    Best regards,
    Peter

    Thread Starter Alvaro Gois dos Santos

    (@alvarogois)

    Hi Peter,

    I’m going to take a look at your examples and get back to you later.

    Thanks for all your help.

    Best,

    álvaro

    Thread Starter Alvaro Gois dos Santos

    (@alvarogois)

    Hi Peter,

    I was unable to deal with your linked material, too complex for my level.

    For now, I focused on the idea of editing a table in the backend with the link.

    Is there a URL parameter that allows me to add a record to a specific table? Your example URL was to edit a record that already exists. What if that record does not exist?

    I have a table I can’t load that way I get an error:
    ERROR: Wrong arguments [no data found]

    Any idea why?

    Thanks.

    álvaro

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Alvaro,

    When you click on the link, which URL is submitted? Please copy your URL into this post. You can remove the domain from the URL for security reasons.

    Thanks,
    Peter

    Thread Starter Alvaro Gois dos Santos

    (@alvarogois)

    Hi Peter,

    I used the same as the one you showed, just changing the table name. So, this one works:

    /wp-admin/admin.php?page=wpda&action=edit&table_name=crmwp_zbs_contacts&ID=7676

    This one doesn’t:

    /wp-admin/admin.php?page=wpda&action=edit&table_name=crmwp_srm_student_discount&ID=7676

    There’s no ID=7676 record. But if I use one that actually exists, I get the same error.

    Also: is there a URL parameter that let’s me add a record to a table pre-populated with a URL variable, like that ID field in the example?

    Thanks.

    álvaro

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Alvaro,

    Is table crmwp_srm_student_discount located in your WordPress database? Or in another database? If the table is located in another database, you need to add the schema schema:
    &wpdaschema_name=you-schema-name

    Please be aware that editing is not possible if the table has no primary or unique key. Can you check please?

    To start an insert, just change your action argument value to new:
    &action=new
    In that case you can skip the ID parameter.

    Does this help?
    Peter

    Thread Starter Alvaro Gois dos Santos

    (@alvarogois)

    Hi Peter,

    Is table crmwp_srm_student_discount located in your WordPress database?

    Yes.

    Please be aware that editing is not possible if the table has no primary or unique key. Can you check please?

    Yes, it has a Primary key that combines that ID field and a course_id field. Should I be using only one database column?

    To start an insert, just change your action argument value to new:
    &action=new In that case you can skip the ID parameter.

    Yes, this works. But is there a way to populate the ID field with the ID parameter? I want to be able to create a record on this table directly from the contact record of the CRM, which means I can use that url parameter to create the record with the right ID pre-filled.

    Thanks.

    álvaro

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Alvaro,

    >>> Should I be using only one database column?

    Don’t worry, the plugin supports primary keys over multiple columns as well and handles them transparently.

    >>> I want to be able to create a record on this table directly from the contact record of the CRM, which means I can use that url parameter to create the record with the right ID pre-filled.

    What if you could add an argument to your url which can be used to add a default value to any column? This could work like adding filter using url parameters:
    https://wpdataaccess.com/docs/documentation/data-projects/adding-filters/#url-parameters
    We could use the prefeix wpda_default_column_ to add a default value just like wpda_search_column_ for a search.

    This is not yet available!! But it seems to be an interesting extension to me for other plugin users as well.

    What do you think?
    Peter

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Editable single record access’ is closed to new replies.