• Resolved cmhello

    (@cmhello)


    After I updated from V5.9.9 to V5.10.0, I found that I could not get posts through ‘query_args’, then I looked at the source code and found that the boxed code in the figure below was very strange:

    meta-box\inc\fields\post.php

    It means “if the current user does not have permission to read the post, then continue” Is it wrong here, it should be “if the current user has permission to read the post, then continue”.

    Then I modified the code as follows, and the function returned to normal:

    if ( current_user_can( 'read_post', $post ) ) {
    continue;
    }

    I hope it can be corrected, thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Tan Nguyen

    (@tanng)

    Dear @cmhello,

    Can you tell me more about where can’t you get the posts so we can reproduce? Do you use frontend submission and anonymous user use that post field?

    Regarding the current_user_can() function, the logic is right, if current user cannot read post, we don’t show the post to user, this to prevent other users, like guests, contributors,… can get the private or password protected posts. The continue keyword is a bit misleading but it just skip the current foreach and continue with the next iteration.

    Cheers!

    Thread Starter cmhello

    (@cmhello)

    I’m sorry, I may have made a mistake, but this is indeed the reason why the plug-in I use does not function properly. I may need to contact the plug-in author to deal with it. Thank you for your reply.

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