WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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' );
share|improve this answer
Is this working also for unregistered users? – M P Aug 11 '13 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. – toscho Aug 11 '13 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 '13 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. – toscho Aug 11 '13 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 '13 at 13:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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