Support » Plugins and Hacks » Hacks » Front-end edit a custom post type with only password sign in?

  • starchcreative

    (@starchcreative)


    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!

Viewing 1 replies (of 1 total)
  • Matt

    (@matttaylor)

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘Front-end edit a custom post type with only password sign in?’ is closed to new replies.