• Resolved cigno76

    (@cigno76)


    Dear Support,

    first of all I wanted to tell you that I love your plugin.

    I need help please:

    If I try to use the file_get_contents function to fetch a post from the site, it shows me the wordpress login form. Is there a way to send credentials with your plugin? An alternative way to get content would also be appreciated.

    Thanks in advance,

    Nicola

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @cigno76,

    Thank you for your feedback, we’re happy to hear you enjoy using WPCode.

    Regarding your request – can you access the post in the browser when you are not logged-in? I’m not sure what you are trying to do with the request but would it be an option to load the post data directly through the WP functions instead of loading it using file_get_contents?

    If you can provide more info about what the snippet is supposed to do we might be able to find an alternative solution.

    Thread Starter cigno76

    (@cigno76)

    Dear Mircea Sandu,
    no, I cannot access the post in the browser when you I ‘m not logged-in.

    This is the url (I replaced the domain):

    https://mydomain.xx/wp-admin/post.php?post=24123&action=edit&lang

    In practice, from the post that displayed in the admin area of ?? wordpress, I want to capture a string from its html code.

    Any alternative would be fine for me.

    Thank you,
    Nicola

    Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @cigno76,

    I see, you can’t access that URL directly using file_get_contents as in that instance you are not logged-in. It should be much easier & safer to grab the value from the database/using a WP function if it’s something specific to that post.

    If you can share what part of the post you are trying to grab I can try to point you to the function you can use to get that directly without having to parse the HTML.

    Thread Starter cigno76

    (@cigno76)

    Hi Mircea Sandu,
    unfortunately it is not information available in the database, the only way is to capture it from the html code.
    thanks for your time,
    Nicola

    Thread Starter cigno76

    (@cigno76)

    Dear Mircea Sandu,
    Do you have any idea how to get a post (kind file_get_contents function) that requires login?

    Best regards,

    Nicola

    Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @cigno76,

    I don’t have a great solution for that, if the value you are trying to load is specific to the post you are editing surely there must be an alternative way to get that. Either through a call to the database or in a similar manner to how it is loaded in the edit screen. Without more context I would just be guessing.

    Sending an authenticated request with file_get_contents is possible but you will need to look into how WordPress authentication works and how you can send cookies with file_get_contents.

    Thread Starter cigno76

    (@cigno76)

    Dear, I understand, anyway thanks for your time

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Get internal post (file_get_contents function) – requires login’ is closed to new replies.