eventespresso / event-espresso-core

Event Espresso 4 Core for WordPress: Build an Event Ticketing Website Today!
https://eventespresso.com
GNU General Public License v3.0
122 stars 87 forks source link

On edit ticket the field Custom Capability always replace autofilled value #4155

Closed tusharkapdi closed 1 year ago

tusharkapdi commented 1 year ago

I am using latest version of EE with advanced editor. Also using latest version addon "WordPress Users Integration"

On Edit Ticket section, I wanted to autofill the field "Custom Capability" on section "WP Users". "Custom Capability" field is not update in database when I autofill the field. It only update if I manually fill or copy/paste capability.

I have added custom dropdown field by customization. And autofill the "Custom Capability" field on selection but the "Custom Capability" field is not update in database. It only update the database if we manually add data.

I have add code for autofill capability field on selection of my custom dropdown. Code is autofill the "Custom Capability" field but when I click in the field the autofilled value is removed. I have tried to remove JavaScript Event Listener and check but then the field is not updated in database.

Can you please provide solution how can I update field? How can I remove event listner which is auto replace the value if it was autofilled?

Please find attached screenshot what I am doing on Edit Ticket screen. Please let me know if any futher information required.

Please help.

Thanks in advance. FireShot Capture 005 - 1 Day Business Tax Course ‹ ISME Skillnet — WordPress_ - ismeskillnet eightyone ie

tn3rb commented 1 year ago

do you have a repo i can look at? there is absolutely no way i can troubleshoot your custom code without seeing any of it 😄 if the repo is private, just add me as a user temporarily, and/or create a new repo (or gist) that ONLY has the code in question

tn3rb commented 1 year ago

i do have one other question though...

Why add a select input for choosing whether ticket is for a member/non-member if you are also going to assign a custom capability to it? If the site visitor is not a member then they won't have the custom capability and therefore won't see the ticket right?

Seems like you are duplicating existing functionality, but maybe there are other reasons i am just not aware of. IMHO anything the additional member/non-member flag can do can also be achieved simply by checking if the current user has the custom capability or not.

ie: (pseudocode)

isMember = has_capability( zoho_member )

or from the ticket point of view:

isMemberTicket = ticket.capabilityRequired === zoho_member

No need for an additional flag IMHO (in my humble opinion)

tusharkapdi commented 1 year ago

Thanks for quick response.

How Can I sent site credential? it is public platform, right?

Please let me know if anything is required.

I have setup Zoho API for membership on wordpress registration page so we required two type of users that is why I have to set custom cabability for two type of users 1. Zoho Member and 2. Zoho Non Member

I have added dropdown for select membership as my client is required selection not type capability in textbox.

Please go to Events -> Edit event name "1 Day Business Tax Course" -> Edit ticket (there is two tickets 1 for Member and 2 for Non-Member)

Auto filled capability always replace or removed it only work when I type manually or copy/paste the text.

Please check and let me know if anything is confusing or any further details are required.

Please help.

tusharkapdi commented 1 year ago

Please let me know if any detail are required.

tusharkapdi commented 1 year ago

Please provide your personal contact details or other way so I can send site credentials.

tn3rb commented 1 year ago

you can email me at brent@eventespresso.com

tusharkapdi commented 1 year ago

Just sent you an email with site credencials. Please check and let me know if anything is required.

tusharkapdi commented 1 year ago

Did you get a change to check? Please let me know if any further details required. Please help!

tusharkapdi commented 1 year ago

Your last comment completed 8 days. Please reply me as I am waiting for you. Please let me know if any further details is required. Please help! My client is eger to find solution. Please help...

tn3rb commented 1 year ago

sorry Tushar, i thought i had responded but gmail blocked my email for some reason:

image

Anyways, you sent me login information to your website. I don't need access to your site, I just need to see your custom code that is attempting to modify the form inputs in the event editor.

For example, here is a link to some code that is used in that area of the form: https://github.com/eventespresso/barista/blob/master/domains/wpUser/src/hooks/useTicketFormInitialValues.ts

In order to help you with your code, I need to see the actual code that you have written.

tusharkapdi commented 1 year ago

Hi, I have uploaded file here - https://github.com/tusharkapdi/ee-testing/blob/main/ee-custom-plugin.php (WordPress Custom Plugin) You can find code related to "Custom Capability" textbox at last function of the file. find commented code "//Advanced Editor code" line number 177 Issues: My code is in line number 190 where I am filling up the textbox by JavaScript (this code is fill the textbox but Event Espresso code is always replace or remove value when click in "Custom Capability" textbox)

Please let me know if anything is required or facing any issues to access code file. Thanks

tusharkapdi commented 1 year ago

Hi, Did you checked? I have to fix this as soon as possible. Please let me know if any further details is required. Please help!

tusharkapdi commented 1 year ago

Please help!

tn3rb commented 1 year ago

Sorry for the delay getting back to you. This turned out to be pretty tricky to solve due to the way that React works under the hood, and it took me a while to find a solution.

The following worked:

jQuery(document).ready(function($) {
    $('body').on('change','#capabilityRequired',function(){
        // get customCapabilityRequired input
        const capInput = document.getElementById("customCapabilityRequired");
        // use HTMLInputElement interface to get native setter
        const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
        // change the value of the input
        nativeInputValueSetter.call(capInput, 'zoho_member');
        // dispatch change event
        capInput.dispatchEvent(new Event('change', { bubbles: true }));
    });
});

I couldn't use the code you posted because it needs to load other files and classes that i don't have access to, but the above should be enough to solve your issue

tusharkapdi commented 1 year ago

Yes, It's works. Thank you very much. Thanks again! I'm happy :)