• Resolved Thomas

    (@thomhsb)


    Hello to the whole team,

    I have a simple function that sends me an email in case of unsuccessful search. Before I installed Relevanssi, it worked fine:

    if( !is_user_logged_in && is_search() && !have_posts() ) { 
    wp_mail($emailto, $subject, $message);
    }

    Since installing Relevanssi, it doesn’t work anymore.

    Please, I’m desperately looking for the hook (action or filter) that can allow me to do the same thing when Relevanssi doesn’t find any result?

    Thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Where is this function running? There’s no reason why this wouldn’t work with Relevanssi, as long as it’s not running in a hook that Relevanssi doesn’t trigger. If this is in the search results template, it should work. Perhaps try debugging it? Which one of the conditions is not producing the expected result?

    Thread Starter Thomas

    (@thomhsb)

    It running via the functions.php of my child theme.

    I just tried it for you:
    If I deactivate Relevanssi, I get an email.
    As soon as I reactivate it, nothing.

    You can try it yourself, here is my function:

    add_action('wp_head', function(){ 
    if(!is_user_logged_in && is_search() && !have_posts()){
    
    $emailto = "my_email";
    $message = "my message";
    $subject = "unsuccessful search";
    
    wp_mail($emailto, $subject, $message);
    }}
    );
    Thread Starter Thomas

    (@thomhsb)

    My bad.
    It must be something else because I have just tested from my preprod website and the email is sent even when Relevanssi is activated.

    Sorry for that and thank you for your support !

    • This reply was modified 2 years, 5 months ago by Thomas.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘action if no result ?’ is closed to new replies.