I have a frontend posting form (CF7), where user inputs (among other data of course) his email. Now I set the status to pending.

What I want is, that the user would get trough autoresponder a mail, in which would be the link for changing the status to PUBLISH when clicked on. Is there any solution for this? Autoresponder is not the problem, I do not know, how to set up this link.

1 Answer 1


When the post is created and set to pending, build a unique identifier for auto-publishing, for example:

$unique = md5( $post->post_content );
add_post_meta( $post->ID, '_auto_publish', $unique );

Now create a link for the email:

$link = get_permalink( $post->ID );
$link = add_query_arg(
        'autopublish' => $unique,
        'pid'         => $post->ID

Send this link in your email to the submitter’s address:

print "<$link>";

Then watch for the matching $_GET parameters when the recipient clicks the link:

if ( isset ( $_GET[ 'autopublish' ] )
    and isset ( $_GET[ 'pid' ] )
    and is_numeric( $_GET[ 'pid' ] )
    and $post = get_post( $_GET[ 'pid' ] )
    and $_GET[ 'autopublish' ] === get_post_meta( $post->ID, '_auto_publish', TRUE )
    $post->post_status = 'publish';
    wp_update_post( $post );
    delete_post_meta( $post->ID, '_auto_publish' );
  • Is this working also for unregistered users?
    – M P
    Aug 11, 2013 at 13:29
  • There is currently no check for registration, so yes, it should work. I haven’t tested this code, it is just an idea.
    – fuxia
    Aug 11, 2013 at 13:30
  • Thanks. Can you please point me where to include this, im quite poor in php. How much you would charge for this to implement (if you have time)?
    – M P
    Aug 11, 2013 at 13:36
  • I would create this as a plugin, see this post. It depends on your form set up where the first part has to to be set. And no, I don’t have much time currently.
    – fuxia
    Aug 11, 2013 at 13:39
  • Ok thanks! In the newsletter I suppose I should then include <a href="<?php echo $link ?>activate</a>, right?
    – M P
    Aug 11, 2013 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.