/** * Creates an user blog post, auto redirects them to the post they have written * * @param: An array containing the post info e.g array( 'postTitle' =>, 'postContent' => ) * */ function nm_edit_user_blog_post($info) { check_admin_referer('user-blog-post_edit'); global $wpdb; $postContent = strip_tags($info['blogContent']); $postTags = $info['blogTags']; if (!is_user_logged_in()) { $feedback = "<p class='message error'>You have to be logged in to write a blog post</p>"; } elseif (!$postTags) { $feedback = "<p class='message error'>Please enter some tags that describe your blog post.</p>"; } elseif (!$postContent || preg_replace('/\\s+/', '', $postContent) == '') { $feedback = "<p class='message error'>You need to write the body of the blog post</p>"; } else { $newPost = array('ID' => $info['ID'], 'post_content' => $postContent, 'post_parent' => $info['blogGroup']); $acc = new ACL($newPost); switch ($info['access']) { case 'hidden': $acc->hidden(); break; case 'members': default: // Just in case something goes crazy $acc->member(); break; case 'friends': $acc->friend(); //public is a php keyword break; case 'public': $acc->everyone(); //public is a php keyword break; } wp_set_post_tags($info['ID'], $postTags); $postId = wp_update_post($newPost); $feedback = '<p class="message success">Blog post updated successfully | <a href="' . nm_get_user_blog_permalink($postId) . '">View ' . get_the_title($postId) . '<a/></p>'; } return $feedback; }
var $post_author; var $post_category; var $post_parent; } $post_category = array($photoCatId, $photoAlbumCatId); $wm_myobject = new wm_mypost(); $wm_myobject->post_title = $photoName; $wm_myobject->post_content = $photoDesc; $wm_myobject->post_status = "publish"; $wm_myobject->post_author = $author->ID; $wm_myobject->post_category = $post_category; $wm_myobject->post_parent = $info['photoGroup']; $acc = new ACL($wm_myobject); switch ($info['access']) { case 'hidden': $acc->hidden(); break; case 'members': default: // Just in case something goes crazy $acc->member(); break; case 'friends': $acc->friend(); //public is a php keyword break; case 'public': $acc->everyone(); //public is a php keyword break; }