Send admin an email when a user’s search has no results

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;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)