I am sending mail with laravel 5.*. but it send whole html view code instead of html preview - laravel-5.3

I have created a view contact-us and mail class in controller as it is following. when i send mail it show the success message and send view contact-us as mail..
$data = ['name' => 'Sunny Mine'];
Mail::send(['text' => 'mail.contact-us'], $data, function($msg){
$msg->to('abc#gmail.com', 'Muhammad Ibrar receiver')->subject('Test Contact Us Form Mail');
$msg->from('def#gmail.com', 'Muhammad Ibrar sender');
});
it send whole html code including html tags but not a webpage preview.. can someone help me to send mail with web view please.

You're forcing the view as text type. Remove the 'text' type and it should work fine.
Mail::send('mail.contact-us', $data, function($msg) {
$msg->to('abc#gmail.com', 'Muhammad Ibrar receiver')->subject('Test Contact Us Form Mail');
$msg->from('def#gmail.com', 'Muhammad Ibrar sender');
});

Related

Reset Password Email Template Wordpress

I have Requirement to change the reset password email template, i have checked the woocommerece email settings and it is on for the reset email from there, but issue is when user request to reset the password it is generating email from there, but using the email content form Wordpress core File
wp-include > user.php
attached it is the screenshot as well.
What i have to do it to remove following section
Regards,
All at ###SITENAME###
So how i can achieve it and if there is any possibilities to enable the Woocommerece template somehow so can directly copy template in my child theme and customize it there?
You can use password_change_email filter for customizing text.
add_filter( 'password_change_email', 'change_password_mail_message', 10, 3 );
function change_password_mail_message(
$pass_change_mail,
$user,
$userdata
) {
$new_message_txt = __( 'Your Text' );
$pass_change_mail[ 'message' ] = $new_message_txt;
return $pass_change_mail;
}

Wordpress Contact Form I can submit to from my Mobile App with API?

I'm looking everywhere for a contact form plugin in Wordpress that would allow me the option to submit to it externally with an API endpoint. I want the client to be able to view submissions within the Wordpress dashboard which is why I'm opting for a plugin but unable to find one that allows me to use it outside of embedding it with a shortcode inside Wordpress itself.
Does a plugin like this exist? If not what are some recommendations for tackling this problem?
Thanks!
You can create custom API endpoint.
https://developer.wordpress.org/rest-api/
function register_custom_route() {
register_rest_route('gn/v1', '/contact', [
'methods' => WP_REST_Server::CREATABLE,
'callback' => 'ajax_custom_',
]);
}
add_action( 'rest_api_init', 'register_custom_route');
function ajax_custom_function( $request ) {
//get contact form value here and integrate with your contact form functionality
$post = $request->get_params();
}
Above function will create endpoint like http://sitename.com/wp-json/gn/v1/contact

WP / Elementor Intercept Form and Redirect with Data

I have a form built in Elementor that I am looking to intercep, process the data and forward onto a third party then subsequently show the data on a "confirm" card.
I am able to build this whole process as a single page, setting each as display none with CSS then showing / hiding with JS as I receive AJAX responses. This isn't ideal as it breaks with JS turned off.
I haven't been able to find the right Elementor hook and way to populate a new page with PHP, has anyone had experience with this?
There are a few methods to POST data to another url from an Elementor web form.
One is using many of the API integrations such as Mailchimp, ActiveCampaign, Zapier etc. (see https://docs.elementor.com/article/281-form-faq) and (https://docs.elementor.com/category/405-integrations)
Another (very limited method) is by using the form's Action after Submit and choosing "redirect" and then using each field's short code as individual data strings in the url such as:
mysite.com/thank-you?fname=[field id="fname"]&lname=[field id="lname"]
You can even build your /thank-you/ page in Elementor to GET that data and populate Elementor elements such as text, title, links etc with the form field data. For example, I could drop a text element on the /thank-you/ page and choose dynamic instead of typing in the text area and from the dynamic drop down, choose "request parameter" and for the "type" choose GET and for the param name use your unique url keys such as fname, lname etc. You can even set prefix, suffix and even fallback text along with it.
Lastly, here is a write up on how to back end code passing data externally (https://developers.elementor.com/forms-api/#Form_New_Record_Action).
// A send custom WebHook
add_action( 'elementor_pro/forms/new_record', function( $record, $handler ) {
//make sure its our form
$form_name = $record->get_form_settings( 'form_name' );
// Replace MY_FORM_NAME with the name you gave your form
if ( 'MY_FORM_NAME' !== $form_name ) {
return;
}
$raw_fields = $record->get( 'fields' );
$fields = [];
foreach ( $raw_fields as $id => $field ) {
$fields[ $id ] = $field['value'];
}
// Replace HTTP://YOUR_WEBHOOK_URL with the actuall URL you want to post the form to
wp_remote_post( 'HTTP://YOUR_WEBHOOK_URL', [
'body' => $fields,
]);
}, 10, 2 );
And a thread with many more examples integrating with different APIs using that template as a primer (https://github.com/elementor/elementor/issues/2397)

Drupal 7 Custom URL in Webform not redirecting

Has anyone found Drupal Webform is ignoring their custom URL in settings?
We set up the form correctly and it had been working previously, however now we're just automatically redirected to the home page with our confirmation message. Any support would be appreciated.
Thanks
In webform submit hook , you can specify redirection :
function my_custom_webform($form, &$form_state){
// Build your form with from api
// add a custom submit if you need , or use core hook_submit
// $form['#submit'][] = 'my_custom_callback_submit';
// for this answer i'll use core hook_submit
return $form;
}
function my_custom_webform_submit($form, &$form_state){
// [.. do some stuff]
// ensure to not have => $form_state['rebuild'] = TRUE;
// because this can't work with redirect
$form_state['redirect'] = 'my/url'; // go to your url
}

Custom notification event in Gravity forms is not attaching PDF

I am using Gravity forms with PDF extension.
I have User notification with event "Form is submitted". In this case, everything works fine, email comes and attachment is there.
But I have created custom event for "User notification" like so:
add_filter( 'gform_notification_events', function( $events ) {
$events['custom_status'] = __( 'Custom status' );
return $events;
} );
But now, email comes, but WITHOUT attachment. Do I have to programmatically tell Gravity forms to attach PDF also on custom events ?

Resources