Example #1
0
function buddyblog_publish_unpublish_on_save($post_id)
{
    if (!empty($_POST['post_id'])) {
        return;
    }
    //check if it is job post type
    $post = get_post($post_id);
    if ($post->post_type != buddyblog_get_posttype()) {
        return;
    }
    //if it is a new post
    if (buddyblog_user_can_publish(get_current_user_id())) {
        //    $active_status=1;
    }
    return $post_id;
}
Example #2
0
/**
 * retusn a link that allows to publish/unpublish the post
 * @param type $post_id
 * @param type $label_ac
 * @param type $label_de
 * @return type 
 */
function buddyblog_get_post_publish_unpublish_link($post_id = false, $label_ac = 'Publish', $label_de = 'Unpublish')
{
    if (!$post_id) {
        return;
    }
    if (!buddyblog_user_can_publish(get_current_user_id(), $post_id)) {
        return;
    }
    $post = get_post($post_id);
    $url = '';
    if (!(is_super_admin() || $post->post_author == get_current_user_id())) {
        return;
    }
    //check if post is published
    $url = buddyblog_get_post_publish_unpublish_url($post_id);
    if (buddyblog_is_post_published($post_id)) {
        $link = "<a href='{$url}'>{$label_de}</a>";
    } else {
        $link = "<a href='{$url}'>{$label_ac}</a>";
    }
    return $link;
}
Example #3
0
 /**
  * Publish Post
  */
 public function publish()
 {
     if (!(bp_is_buddyblog_component() && bp_is_current_action('publish'))) {
         return;
     }
     $id = bp_action_variable(0);
     if (!$id) {
         return;
     }
     if (buddyblog_user_can_publish(get_current_user_id(), $id)) {
         wp_publish_post($id);
         //change status to publish
         bp_core_add_message(__('Post Published', 'buddyblog'));
     }
     bp_core_redirect(buddyblog_get_home_url());
 }