Hello,
I am trying to add a few custom modifications to a classifieds theme for Wordpress. It uses custom fields to get all the information in a post. Phone number, location, price, etc. It was designed to send an email to the user, the user clicks a confirmation link which has a password which is already generated. Basically I would like to change the script around a bit so that a logged in user would not have to go through all the email confirmation process.
I got it to not send the email ... and I got stuck.
Code which adds the post but sends email(if more of the code is needed please let me know):
if (!$error){
// post information
$data = array
(
'ID' => cG("post"),
'post_status' => "publish"
);
// update post
wp_update_post($data);
// post information
$data = array
(
'post_title' => cP("title"),
'post_content' => cPR("description"),
'post_status' => "draft",
'post_category' => array(cP("category")),
'tags_input' => cP("tags")
);
// insert post
$published_id = wp_insert_post($data);
$post_password = generatePassword();
// add custom fields
if (cP(contact_name)!="") add_post_meta($published_id, 'contact_name', cP("contact_name"), true);
Now this is what actually gets the post from draft to published:
<?php if (cG("pwd") && is_numeric(cG("post"))) : ?>
<?php if (cG("pwd")==get_post_meta(cG("post"), "password", true) && cG("action")=="confirm") :
// post information
$data = array
(
'ID' => cG("post"),
'post_status' => "publish"
);
// update post
wp_update_post($data);
?>
<div class="intro">
<p><?php _e('Your ad has been confirmed, thank you', "wpct"); ?></p>
I was thinking of using the below code to directly publish the post if the user is logged in and if not, the regular email confirmation.
<?php
if ( is_user_logged_in() ) {
global $current_user;
get_currentuserinfo();
echo 'Welcome, registered user!';
echo 'User ID: ' . $current_user->ID . "\n";
} else {
echo 'Welcome, visitor!';
};
?>
Any help will be appreciated.
Thank you!