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:
- wp_mail and BCC headers
- How to get current post ID in Contact Form 7 wpcf7_before_send_mail hook action
- Send email when a new post is published [closed]
- Email Notifications of new posts to users – suggestions [closed]
- How to override normal WordPress search in Buddypress? [closed]
- Search and replace text across all posts
- How to add usermeta to “Notice of Email Change” email message
- Notify commenters about new replies
- dynamic page not indexed
- How to get posts by content?
- Problem with Search Results in WP (not displaying the full posts)
- How to improve WordPress search
- Server-side subscribe by email?
- WP Mail SMTP: What do the SSL/TLS options mean? [closed]
- Creating search filter through plugin
- wp_mail() is not working on server
- Storing a password for use with a WordPress plugin
- Is there a plugin to record querystring parameters for a page (for customer tracking)? [closed]
- Storing Email Account Passwords for SMTP Mailing for a WordPress Plugin
- action-scheduler vs wp-background-processing
- Automatically adding category filter based on search string
- Easy Digital Downloads (EDD) – Purchase Receipt emails couldn’t be logged
- How can I reuse the WordPress search form for a custom plugin / widget?
- WordPress sending emails continuously. How to stop it?
- wp_mail attachment not working
- 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
- What causes an Unexpected HTTP Error within install plugins?
- Woocommerce email template customization [closed]
- Hook into and send mail using WP Mail SMTP type plugin from HTML static front page?
- Email Bounce Address
- Search is not working on plugin directory
- Search Everything plugin integration
- AJAX search posts and pages
- How to send an automated email to the customers when product is added woocommerce
- Search for categories
- Looking for a way that will collect visitors emails before letting them view the blog posts [closed]
- Send email when a portfolio project is updated
- Notify comment author upon reply
- Implementing an “Email this” button?
- 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
- How to set “split_on_numerics” to false in ElasticSearch mapping using ElasticPress? (for proper SKU search in WooCommerce) [closed]
- Send email with list of active plugins upon activation/deactivation
- WordPress: Add custom add_filter for custom functions
- 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?
- Cron job emails blank
- Form tries to download a file on submit
- How to make wp multisite subdomain exist search
- Remove Url Parameter WordPress
- 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
- Can we install 3d product configurator into wordpress
- How to set an exact search box in tablepress plug-in
- additional fields based on the quantity of products selected