Skip to content
This repository has been archived by the owner. It is now read-only.

Cannot Comment Without Being Logged In #2960

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

Comments

Projects
None yet
5 participants
@noamichael
Copy link

commented Dec 10, 2016

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

This comment has been minimized.

Copy link
Member

commented Dec 10, 2016

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

This comment has been minimized.

Copy link
Author

commented Dec 10, 2016

@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

This comment has been minimized.

Copy link
Member

commented Dec 10, 2016

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

@BE-Webdesign

This comment has been minimized.

Copy link
Member

commented Dec 10, 2016

@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

This comment has been minimized.

Copy link
Member

commented Dec 10, 2016

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

@noamichael

This comment has been minimized.

Copy link
Author

commented Dec 10, 2016

@websupporter @BE-Webdesign

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

@websupporter

This comment has been minimized.

Copy link
Member

commented Dec 10, 2016

Great :) Glad we were able to help.

@ChrisSargent

This comment has been minimized.

Copy link

commented Dec 14, 2016

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

@wilburt

This comment has been minimized.

Copy link

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.
You can’t perform that action at this time.