Support » Plugin: Contact Form 7 » CF7 keeps spinning and wait time is long

  • Resolved celin007

    (@celin007)


    Hi,

    I’m using Contact form 7 as the contact form for my website. I notice that recently my websites upgraded to PHP 7.4.19 and moved to the new server. Since that the contact form keeps spinning and not sending emails.

    However I noticed that domain/wp-json/contact-form-7/v1/contact-forms/1788/feedback was not working due to a security fix, when removed the code it works but still spinning time is too long.

    The code removed due to the issue is as below. It was to block user information from WordPress sites, even though removing the code is a temporary workaround to make CF7 working, I probably want to keep the code to avoid anyone fetching user information.

    // To disable REST API to pull user details 
    add_filter( 'rest_authentication_errors', function( $result ) {
      if ( ! empty( $result ) ) {
        return $result;
      }
      if ( ! is_user_logged_in() ) {
        return new WP_Error( 'rest_not_logged_in', 'You are not currently logged in.', array( 'status' => 401 ) );
      }
      if ( ! current_user_can( 'administrator' ) ) {
        return new WP_Error( 'rest_not_admin', 'You are not an administrator.', array( 'status' => 401 ) );
      }
      return $result;
    });

    You can find the errors at https://snipboard.io/JXSnu5.jpg

    Can you please help me to solve this issue and make CF7 perform faster?

    Thanks
    Celin

    • This topic was modified 4 months ago by celin007.
    • This topic was modified 4 months ago by celin007.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Erik

    (@codekraft)

    hi @celin007

    you may want change this:
    if ( ! is_user_logged_in() ) {
    and exclude the “wp-json/contact-form-7/” from returning an error.

    but if you want to avoid anyone fetching user information check this

    Thread Starter celin007

    (@celin007)

    Hi Erik,

    Thank you for the quick response. I have included the code if ( !is_user_logged_in() && empty($_POST[‘_wpcf7’]) ) {
    But it is still refusing to connect using REST and keep spinning. So I removed the code again.

    Can you please provide me the exact conditional check?

    Thanks

    Thread Starter celin007

    (@celin007)

    Also added the following code but the same issue of spinning happens

    add_filter( ‘rest_endpoints’, function( $endpoints ){
    if ( isset( $endpoints[‘/wp/v2/users’] ) ) {
    unset( $endpoints[‘/wp/v2/users’] );
    }
    if ( isset( $endpoints[‘/wp/v2/users/(?P<id>[\d]+)’] ) ) {
    unset( $endpoints[‘/wp/v2/users/(?P<id>[\d]+)’] );
    }
    return $endpoints;
    });`

    Erik

    (@codekraft)

    yes I was pointing that:

    add_filter( 'rest_endpoints', function( $endpoints ){
        if ( isset( $endpoints['/wp/v2/users'] ) ) {
            unset( $endpoints['/wp/v2/users'] );
        }
        if ( isset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] ) ) {
            unset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] );
        }
        return $endpoints;
    });

    what is exactly the route you want to deny? with the previous code you can’t list users and cf7 seems to work. can I take a look at your website?

    Thread Starter celin007

    (@celin007)

    I want to block users information using /wp-json/wp/v2/users.

    Yes when I used the code CF7 was keep spinning and when removed the code it works
    `add_filter( ‘rest_endpoints’, function( $endpoints ){
    if ( isset( $endpoints[‘/wp/v2/users’] ) ) {
    unset( $endpoints[‘/wp/v2/users’] );
    }
    if ( isset( $endpoints[‘/wp/v2/users/(?P<id>[\d]+)’] ) ) {
    unset( $endpoints[‘/wp/v2/users/(?P<id>[\d]+)’] );
    }
    return $endpoints;
    });

    Erik

    (@codekraft)

    this is the reason why I suppose some other plugin makes some noise! 🙂

    test by yourself
    https://modul-r.codekraft.it/wp-json/wp/v2/users

    but the form works correctly
    https://modul-r.codekraft.it/test-form

    antispam alert – act like a human! (send the form at least after x seconds, click and move the mouse etc)

    Thread Starter celin007

    (@celin007)

    I get the message “There was an error trying to send your message. Please try again later.” when trying to submit the form from https://modul-r.codekraft.it/test-form.

    Thread Starter celin007

    (@celin007)

    Please try to log out of the website and try to send the form again. It worked for my website when I was logged in.

    Erik

    (@codekraft)

    Sorry you was blocked by the antispam! it’s the dev version of a under development plugin! I unbanned you could try again? (ps after the first spam detection you can’t send for a while mails from that ip because you will be automatically rejected)

    I have tried and it works even from anonymous session, so i’m pretty sure!

    Thread Starter celin007

    (@celin007)

    Great, yes it works for me. Does the spam detection base on email ids? I have used a random email id maybe that’s the reason?

    Did you use the code below or any other modifications?

    `add_filter( ‘rest_endpoints’, function( $endpoints ){
    if ( isset( $endpoints[‘/wp/v2/users’] ) ) {
    unset( $endpoints[‘/wp/v2/users’] );
    }
    if ( isset( $endpoints[‘/wp/v2/users/(?P<id>[\d]+)’] ) ) {
    unset( $endpoints[‘/wp/v2/users/(?P<id>[\d]+)’] );
    }
    return $endpoints;
    });

    Thanks for your support.

    Erik

    (@codekraft)

    (this is not the place to talk about it) I’m trying to make an antispam that has different way to stop the different types of bots. the reason was timeout and listed in dnsbl.


    Yes exactly that code appended at the end of functions.php (in the worst way… with the theme editor because i’m lazy but works as intended).

    Do you have any wordpress security plugin or any function in the template related to wp api?

    • This reply was modified 4 months ago by Erik.
    Thread Starter celin007

    (@celin007)

    I have added this line of code to function.php and works perfectly fine. No security plugin or function related to wp API is used. Thanks for your help.

Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.