Beispiel #1
0
function nh_save_as_draft($form)
{
    global $post;
    $item_key = $_GET['entry'];
    $current_status = 'draft';
    $tmp_item_id = nh_get_frm_key_id($item_key);
    $tmp_post_id = nh_get_frm_id_post_id($tmp_item_id);
    if ($form->id == 12 and $_GET['ref'] == 'update') {
        $new_post = get_post($tmp_post_id, 'ARRAY_A');
        $tmp_post = get_post($tmp_post_id);
        $tmp_author = $tmp_post->post_author;
        $new_post['post_status'] = $current_status;
        $new_post['post_author'] = $tmp_author;
        wp_update_post($new_post);
    }
}
Beispiel #2
0
		<div id="main">			
			<div id="content">
<h3 class="page-title">Edit Your Content</h3>

<?php 
// Get guide cat id
$guide_cat = get_category_id('guides');
$stories_cat = get_category_id('stories');
$resources_cat = get_category_id('resources');
$blog_cat = get_category_id('blog');
// Get current user
global $current_user;
get_currentuserinfo();
// Get the entry info
$item_key = esc_attr($_GET['entry']);
$item_id = nh_get_frm_key_id($item_key);
$item_post_id = nh_get_frm_id_post_id($item_id);
$entry_info = get_post($item_post_id);
$btn_preview = '<li style="float:right;margin-left:1em;"><a href="' . $app_url . '/?post_type=post&p=' . esc_attr($item_post_id) . '&preview=true" title="See what your Guide will look like" target="_blank"><button class="nh-btn-blue-med">Preview Guide</button></a></li>';
?>

<?php 
$mypost = get_post($item_post_id);
//var_dump($mypost);
//var_dump($current_user->ID);
//var_dump($mypost->post_status);
if ($current_user->ID == $mypost->post_author and is_user_logged_in()) {
    // LOGGED IN AND IS AUTHOR
    if ($mypost->post_status == 'draft') {
        if ($_GET['ref'] == 'create') {
            echo '<div class="alert alert-info"><a href="#" class="close" data-dismiss="alert">×</a><strong>Thank you for writing a CityHow Guide!</strong><p>Your Guide has been saved as a Draft, so you can keep working on it until you&#39;re ready to publish.</div>';