Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jeff Starr

    (@specialk)

    The plugin basically is one line of code, so there is not a lot that can be done. Are you getting any related error or clues that might be useful?

    Plugin Author Jeff Starr

    (@specialk)

    Hi @maria003, do you still need help with this?

    Thread Starter maria003

    (@maria003)

    yes, need help.

    Plugin Author Jeff Starr

    (@specialk)

    The plugin basically is one line of code, so there is not a lot that can be done. I will ask again though, are you getting any related error or clues that might be useful?

    Plugin Author Jeff Starr

    (@specialk)

    One more try, are you getting any related error or clues that might be useful?

    atomicacorn

    (@atomicacorn)

    We had this same issue, @maria003, you need to whitelist the call made by contact 7 form, by adding in a few lines to the disable-wp-rest-api.php file in the plugin (apologies @specialk if this is not the correct or intended use of the plugin, also great plugin, thanks ?? saved me a lot of headaches):

    #in disable-wp-rest-api.php update the disable_wp_rest_api function with something like this:
    
    function disable_wp_rest_api($access) {
            # note, your url here is probably different! check the console log for where the REST request is going
    	$allowed_uris = ["/wp-json/contact-form-7/v1/contact-forms/4/feedback", "/wp-json/contact-form-7/v1/contact-forms/4/feedback/"];
    
    	if (!is_user_logged_in() && !(in_array($_SERVER['REQUEST_URI'], $allowed_uris))) {
    		
    		$message = apply_filters('disable_wp_rest_api_error', __('REST API restricted to authenticated users.', 'disable-wp-rest-api'));
    		
    		return new WP_Error('rest_login_required', $message, array('status' => rest_authorization_required_code()));
    		
    	}
    
    	if (is_user_logged_in() && !(in_array($_SERVER['REQUEST_URI'], $allowed_uris))) {
    		
    		$message = apply_filters('disable_wp_rest_api_error', __('REST API restricted.', 'disable-wp-rest-api'));
    		
    		return new WP_Error('access_denied', $message, array('status' => rest_authorization_required_code()));
    		
    	}
    	
    	return $access;
    	
    }
    
    • This reply was modified 4 years ago by atomicacorn. Reason: added comment to note the allowed uri may be different for the op
    Plugin Author Jeff Starr

    (@specialk)

    Thank you for sharing, @atomicacorn ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘After active Disable Rest API, Contact form 7 doesn’t work’ is closed to new replies.