Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Cannot Comment Without Being Logged In #2960

Closed
noamichael opened this issue Dec 10, 2016 · 11 comments
Closed

Cannot Comment Without Being Logged In #2960

noamichael opened this issue Dec 10, 2016 · 11 comments
Labels

Comments

@noamichael
Copy link

Hey guys,

So, I'm using the latest version of the WP-API, and it appears that I am unable to submit a comment without being logged in. My wordpress settings allow for anyone to comment.

My request looks like this:

POST
http://www.example.com/wp-blog/wp-json/wp/v2/comment?post=124&content=Hello_world&author_name=Me&email=Me%40example.com
Response => {
            "code":"rest_comment_login_required",
            "message":"Sorry, you must be logged in to comment.",
            "data":{"status":401}
}

Is there anyway to do this with the current API?

@websupporter
Copy link
Member

Hi noamichael,
anonymous comment by default is disabled with the 4.7 API. However, there is a filter, you can use:
add_filter( 'rest_allow_anonymous_comments', '__return_true' );

should do the trick.

@noamichael
Copy link
Author

@websupporter

Thanks for the quick reply! Where would you add that definition? I'm not too familiar with PHP and I don't know where the standard place to add such a definition would be.

@websupporter
Copy link
Member

websupporter commented Dec 10, 2016

One place could be your (child) themes functions.php

@BE-Webdesign
Copy link
Member

@noamichael,

The best option is to create a simple plugin file, alternatively you can place it in a themes functions.php. If you place the code into a theme file, when you change your active theme the functionality will be lost.

@BE-Webdesign
Copy link
Member

Closing this out as this is not a bug/enhancement for the API. Feel free to continue discussion here.

@noamichael
Copy link
Author

@websupporter @BE-Webdesign

Thank you for the speedy support, guys. I can now comment as expected.

@websupporter
Copy link
Member

Great :) Glad we were able to help.

@ChrisSargent
Copy link

3 hours later of wondering why it wasn't working.... thanks! Might have been nice for someone to mention this: https://codex.wordpress.org/Version_4.7

@wilburx9
Copy link

wilburx9 commented Feb 3, 2017

So how do we post the comment with the user authenticated?

@WP-API WP-API locked as spam and limited conversation to collaborators Apr 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants
@websupporter @noamichael @ChrisSargent @BE-Webdesign @wilburx9 and others