Why is there an error when submitting the form? - wordpress

Please tell me how to solve the problem.
The site is on Wordpress, the page has several modals with forms.
They all work well. I need to configure adding an email to the Sendpulse address book, which the user enters into the field.
Installed the sendpulse package via composer: https://github.com/sendpulse/sendpulse-rest-api-php
The situation is this:
In the directory with the theme, there is a functions.php file where there is a form handler, in which you can configure sending letters with requests from forms.
In this file, I added, according to the instructions from github sendpulse, the code for sending an email to the address book:
require '../private/vendor/autoload.php';
use Sendpulse\RestApi\ApiClient;
use Sendpulse\RestApi\Storage\FileStorage;
define('API_USER_ID', 'b7****************************************');
define('API_SECRET', 'e1*************************************');
$SPApiClient = new ApiClient(API_USER_ID, API_SECRET, new FileStorage());
$bookID = '15********';
$emailForSP = ['test6#test.ru'];
$SPApiClient->addEmails($bookID, $emailForSP);
If you just add this piece to the beginning of the file, then it works out and the address is added to the book. But sending letters to mail does not work, an error is thrown: https://hsto.org/webt/v8/qn/le/v8qnled6ibyy-ltp9afwyrjv-2q.jpeg
In the error_log file the line is: https://hsto.org/webt/mk/vo/g0/mkvog03mb7olfji0qrjcsyxktf0.jpeg
Error text from main.js file: https://hsto.org/webt/cd/-n/ry/cd-nryfx06_mvgtglu-t9msp8ga.jpeg
That is, this piece of code somehow affects the processing of the form handler function. In general, I need to trigger sending an email to the book after sending a letter to the mail, but in this case nothing works at all.

I didn't look for the cause of the conflict for a long time. Allocated sending e-mail in the sendpulse into a separate file and added ajax post request to this file. I don’t know why I hadn’t thought of this before.
let emailForSendPulse = $form.find('[name="email"]').val();
$.post('/wp-admin/smth.php', {email: emailForSendPulse}, function(data){
console.log('Form sended');
});

Related

Yahoo OAuth Invalid Client ID

I'm trying to connect my ASP.NET Core 3.1 web app with Yahoo. To do this, I have to set up Authorization with OAuth. I have followed a few different guides, including:
https://developer.yahoo.com/oauth2/guide/openid_connect/getting_started.html
https://www.yogihosting.com/implementing-yahoo-oauth-2-0-in-csharp-and-asp-net/
I have set up my app in Yahoo, with the configuration found in the below picture:
I then have my code set up to send the authorization request to Yahoo with the following code:
public void YahooAuth()
{
string id = configuration["YahooClientId"];
string returnUrl = "https://www.fantasysimmer.com/FootballSimulator/Sim";
string url = $"https://api.login.yahoo.com/oauth2/request_auth?client_id={id}--&response_type=code&redirect_uri={returnUrl}";
Response.Redirect(url);
}
When this code is ran however, I get an error page with a message "Developers: Please specify a valid client and submit again.", and the URL displays:
https://api.login.yahoo.com/oauth2/error?client_id={Client_ID}--&error=unauthorized_client&error_description=invalid+client+id
I double and triple checked the Client ID, and the client ID in the URL is the same as in my Yahoo App's profile. I'm wondering now, is there an extra step that I missed in registering my app, or is there something wrong with my code?
Edit: Progress is made! The dashes after the client id must have been part of the example, or otherwise were an error. When I removed that, I started getting a new error, saying to enter in a valid request. It had something to do with my return url, because replacing that with 'oob' made it go through.
So there were two errors. The first was that the "--" after the client id were not supposed to be there. I'm not sure why in yahoo's example they have them there, but they aren't needed. The second reason is that my return uri was capitalized in my code, but not capitalized in my app settings. Now it works!

How to pass parameters from Wordpress Contact Form 7 to an external server?

I have a login form created in Wordpress using Contact form 7. I'm tryig to pass parameters from this form to an external server. But it is not happening.
I am a designer, and not much of a programmer. I understand code(sometimes) but can not write it from the scratch.
I have designed a website for a client. This client has a "Flying Returns" like logistic membership system in which members get lots of perks in shipping etc. This system is on their own server. They want the users to log in to that system from this website.
So I have created a login form using Contact Form 7. I have set skip_mail: on; I have tried a few plugins login, but either they dont log into different servers or are expensive, or does not yield correct URL and hence does not log into the system. Therefore I have finally decided to make it happen using code.
Their programmer has given me following JS code that will take the parameters from this form and pass on to their system. IF the parameters are correct, then the user is logged into the system and taken to the member's dashboard page on their server (not my website/server), else it returns an error message, {"error":"Login Data Incorrect.."}
I have tried to put this code with in the contact form. Here is the code (i've hidden the actual IP address, sorry):
<script>
document.addEventListener( 'wpcf7submit', function( event ) {
alert( "Fire!" );
document.location.href="http://49.XXX.XXX.202:XXXX/glslink/servlet/GPLogin?password="+$('#password').val()+"&emailid="+$('#emailid').val();
}, false );
</script>
If I remove the document.location line, it shows the alert. But the above, in its entirety does nothing. If I use the URL, replace variables with actual values and paste it browser, it logs me into the system without a hitch.
I have tried quite a few different codes which I could find as possible solution on internet, this site including, but to no avail.
Please help me out. I want the email and password to be passed to this external server, if they are correct then the user should log in and see their dashboard there. Else if it gives the above mentioned error message, then I should be able to reset the form and give an error message to the user.

Can't reset user's password in Google Identity Toolkit: "CAPTCHA_CHECK_FAILED"

I'm trying to setup my Google Identity Toolkit so users can reset their passwords. I'm following the documentation here: https://developers.google.com/identity/toolkit/web/required-endpoints#send_email_url
I'm using the PHP Gitkit Client outlined here: https://github.com/google/identity-toolkit-php-client/blob/master/src/GitkitClient.php
Specifically the function getOobResults() on line 307 seems to be unhappy for some reason. Here's where I'm at:
User sets up account and logs in successfully
User then logs out and starts to log back in, enters email in and clicks "Forgot password"
reCaptcha is shown, click check box and then hit continue
At this point my 'Send Email URL' endpoint (gitkitEmail.php) is successfully called and the following POST is set to it (dropping the full '&response' param since it goes on for a while):
action=resetPassword&email=xodfebefa%40nada.ltd&challenge&response=03ACgFB9tGlNt2KAGhrVY....
I then take that string and parse it using parse_str(); since getOobResults() is looking for an array. However, response I get back is always:
{
"response_body": {
"error": "CAPTCHA_CHECK_FAILED"
}
}
I searched around but can't find any details on this error. Any help would be appreciated. I don't have a reCaptcha setup anywhere on my site, unsure if this is expecting me to do that and that's why it's failing? Also, I did bump all my code to a production environment and got the same error there as I did on my localhost.

IIS 7.0+ HTTP PUT Completes, but No File Saved

I'm struggling to figure out what exactly is happening. I am using GdPicture to save a scanned document through java script using their COM+ code and source project as my starting ground. Long story short is their function issues a HTTP PUT command specifying the file name to be saved.
When I execute the command I see that the request is getting to my server, and even has the appropriate content size to include the pdf document. I even get a 200 response back to my browser, no errors or anything...... yet the pdf doesn't get saved. Is that because PUT isn't the right way to do this? I don't have the option to POST the file because the transfer is wrapped in GdPicture's api... so with that said.
I have done the following
Ensured that IIS_IUSRS group has write permissions to the "Upload" virtual directory
Added a handler that specifically allows the PUT verb for "*.pdf"
Removed the StaticFileHandler for the "Upload" virtual directory
I aplogize for the links, but I don't have 10 rep points yet
PUT Request from FIDDLER
Response
** Edit **
More information about GdPicture, I have already contacted them and their function is not the problem. The implementation is as simple as
var status = oGdViewer.SaveDocumentToPDF_2("http://domain.com/Annotation/Upload/" + FileName, "user", "pass");
Thanks!

Magnolia CMS's built-in Form: SMTP configuration overriding "From" input

On the following page http://documentation.magnolia-cms.com/modules/mail.html#ConfiguringSMTP
In the section "Sending messages >> Plain text and HTML messages", we can read:
From:[...]Regardless of the address entered here, Magnolia CMS will use the smtpUser to send the email but the address here is displayed as the sender to the recipient. This means you can send an email from fake#address.com and it will appear to come from this address
However, when I receive the email I can still see the smtpUser config's email and my "fake#address.com" email address is not displayed (it is ignored!?)
Am I missing something? Thanks
I just tried this on the demo site at http://demoauthor.magnolia-cms.com/demo-project/service/contact.html and it seemed to work as expected.
Are you using a fresh install of Magnolia 4.4.5? Could you verify that you're hitting the "Edit Form Settings" button on the page, going to the "E-Mail" tab, and entering "fake#address.com" into the From field there? If you're then trying the form on a public instance, you'll need to be sure that the form page has been activated so that the public version of it has your "From" setting as well.

Resources