• alllllllllll

    (@alllllllllll)


    I have a classified ads type site where guests can create posts (custom post type).

    Creating the new post works fine for logged in users.

    When guests try to create a post the slug does not get set. The post itself still gets created but the slug, category, and tags are all left out.

    $post = array(
    	'post_title' 	=> $_POST['title'],
    	'post_name'		=> $slug,
    	'post_author' 	=> 1,
    	'post_content' 	=> $_POST['content'],
    	'post_type' 	=> 'classifieds',
    	'post_status' 	=> 'pending',
    	'tags_input' 	=> $tags,
    	'tax_input' 	=> array('cat' => $term_id)
    );

    Does a user have to be logged in to create a post? Is there something I’m missing?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Pioneer Web Design

    (@swansonphotos)

    Does a user have to be logged in to create a post?

    If you prefer to stay online, yes…

    Thread Starter alllllllllll

    (@alllllllllll)

    I mean an anonymous visitor on my site.

    $post = array(
    	'post_title' 	=> $_POST['title'],
    	'post_name'		=> $slug,
    	'post_author' 	=> 1,
    	'post_content' 	=> $_POST['content'],
    	'post_type' 	=> 'classifieds',
    	'post_status' 	=> 'pending',
    	'tags_input' 	=> $tags,
    	'tax_input' 	=> array('cat' => $term_id)
    );
    $the_new_id = wp_insert_post( $post);

    If a guest on my site runs that, should that create a new post?

    Pioneer Web Design

    (@swansonphotos)

    I mean an anonymous visitor on my site.

    Please do not allow ‘anonymous users’ to include site content…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problems with creating post programmatically for guest.’ is closed to new replies.