WordPress.org

Ready to get started?Download WordPress

Forums

Front-end edit a custom post type with only password sign in? (2 posts)

  1. starchcreative
    Member
    Posted 1 year ago #

    This could be a tricky — I hope someone can help! As well I know it sounds weird to be doing but it's important.

    Context: I have a custom application in WordPress that is based on registered and unregistered users posting custom post types from the front end. Editing posts would also be done with a front end editor.

    Problem: Obviously the users that are registered will only need to sign in to edit their posts, but what I need to do is allow unregistered users to set a post password when creating the post and present them with only a password field when they would like to edit their post. Essentially they would enter the password they set (and a hidden field would reference the referring post ID) and it would log them in and present them with the edit screen—the same as a registered user would see if they logged in and edited their posts. I understand the security risks here.

    Hope someone can help! Thanks!

  2. Matt Republic
    Member
    Posted 1 year ago #

    Hi starchcreative,

    If I'm understanding your question correctly one possible (and untested) way you could do it is this:

    if ( is_user_logged_in() ) {
        // display edit_post_link();
    }
    elseif ( post_password_required() ) {
        // display get_the_password_form();
    }

    The function wp_insert_post() will be your friend here.

Topic Closed

This topic has been closed to new replies.

About this Topic