You haven’t provided much info so I will give you a basic example.
You need to find whatever template your theme is using to display the results, possibly search.php. If this isn’t your theme create a child theme and duplicate the file that displays the results.
This file should already have an if statement for displaying the results, possibly an if/else. If not you will need to add one. The Else is used for when there are no results. You can grab what was entered in the search with get_search_query().
Inside the else you can use wp_mail() to send an email.
For Example:
if ( have_posts() ) : while ( have_posts() ) : the_post();
// Code to display your results
else:
// No results so send an email
$query = get_search_query();
$to = '[email protected]';
$subject="User Search";
$message="User searched " . $query;
wp_mail($to, $subject, $message );
endif;
Related Posts:
- Disable email notification after change of password
- wp_mail and BCC headers
- Sending all emails using SMTP
- How to make search engine index PDF files? [closed]
- Email Notifications of new posts to users – suggestions [closed]
- How would implement StackExchange ‘Questions with similar titles’ for the FAQ on my wordpress site
- How to add usermeta to “Notice of Email Change” email message
- WP-PageNavi plugin doesn’t work with multiple pages of search results
- Send batch of posts as HTML Email?
- Is there a plugin that allows a user of your site to get an email from you with an attachment?
- Plugin for Sending Email to Readers about New Posts? (besides “Subscribe2 “)
- How to improve WordPress search
- How to bulk send emails
- WP Mail SMTP: What do the SSL/TLS options mean? [closed]
- Creating search filter through plugin
- How do I add advanced custom fields / meta fields to Elasticsearch? [closed]
- wp_mail() is not working on server
- plugin to search entire posts, blogs, forum, users [closed]
- A very basic question – how to properly use wp_mail() in a plugin
- WordPress plugin for mail subscriptions [closed]
- Is there a plugin to record querystring parameters for a page (for customer tracking)? [closed]
- How can I reuse the WordPress search form for a custom plugin / widget?
- wp_mail attachment not working
- Setting Custom Email From name and email address in wp_email()
- how to incude logo in contcat form 7 email [closed]
- Check if email address exists front end with AJAX in a plugin
- Custom Taxonomy Tag Search
- Sending email from inside a plugin using PHP PEAR
- What is the best way to mimic a search query within a plugin
- Can’t send mails using contact plugin [closed]
- Is there a way I can find wordpress posts that don’t contain a word?
- Hook into and send mail using WP Mail SMTP type plugin from HTML static front page?
- Email Bounce Address
- WordPress Registration Email by Role
- Search Everything plugin integration
- Get sent emails without email logs
- Looking for a way that will collect visitors emails before letting them view the blog posts [closed]
- Display encrypted content on my website
- Sending HTML emails via wp_mail not working properly
- Notify comment author upon reply
- How to multiply a post to test internal search results?
- Looking for advice for a mail sending plugin
- How to check if an email was sent from or originated from a specific plugin?
- Plugin to email a post or page to someone
- Collecting email addresses via a “beta” sign up form
- Send email with list of active plugins upon activation/deactivation
- Getting 400 Error: redirect_uri_mismatch when trying to grant permission to Gmail SMTP plugin
- Search and Filter Plugin – How to disable redirection
- sending different email notification while registration based on user role
- WordPress Multi-Step Product Search
- Function added to hook “new_to_publish” not executing – custom plugin
- Custom search search does not work?
- Two WooCommerce installations on the same server, one sends customer emails but the other does not
- Contact Form 7 Plugin emails not being received by some accounts
- Plugin to send messages to members/lists but not full-blown newsletters
- In wordpress how to sent different email separetly when i click on different email ids [closed]
- Mass Mail Plugin to Email Specified User Roles [closed]
- Best approach to make all tags searchable by the wordpress search function
- WordPress – send digital product with custom email
- RSS feeds for specific topics
- How to add the search page link to the anchor tag?
- How to create a form where you can select multiple recipients, based on a list of website users?
- WC Fix Attributes – ‘Add New’ Not Searchable/Delayed
- SMTP emails not picking up the correct From name and From email
- How to hide an option from dropdown in filter module
- I want to schedule email (date, time is in database->table) wp_schedule_event() not working
- Search results to point to specific section?
- How to change a wordress plugin php code in my child’s functions.php file?
- Search in WordPress
- Content disappears when searching with Search & Filter plugin
- Send email when a user registers Rest api
- Accounting for search terms that may include a space, using SearchWP
- How to send custom mail when a user complete a specific form
- Do_shortcode before send email content
- Use WordPress Site For Email List Functionality
- how to add navigation icons in specific template?
- Form tries to download a file on submit
- How can I automatically send an email with an excel file containing submissions for a form rather than an email per submission?
- Include post_date in search
- How to order users alphabetically by name? in plugin UPME
- Add “selected” class to custom taxonomy dropdown search
- Differentiate attachment pages in search results
- Setup SMTP setting in wordpress
- how to sort results by last day update at search result in plugin installer?
- Choose User to email when adding a new post?
- Automatically send an email to list when blog is updated
- Strange Search Query Appearing on Google Index – “/?q=Save+Us+From+Berlusconi”
- wordpress Search function is not working
- How to work email subscribe in WordPress?
- Send Processing Order Email from custom payment plugin
- Send email notification when meet the condition
- WordPress isn’t sending welcome email with the password reset
- How to set an exact search box in tablepress plug-in
- additional fields based on the quantity of products selected
- Autocomplete search field that is feed by a taxonomy from custom post type?
- Create index for own custom data in elasticpress from wordpress plugin
- search by meta field in the regular WordPress admin panel search
- Email notification when registred user clicks a link/visits page
- How do I set WordPress to send 2 different emails based on criteria in the database when someone submits a form?
- SMTP email does not work even with the right firewall rules