WordPress.org

Forums

PHP/MySQL code to create new post (4 posts)

  1. jtreminio
    Member
    Posted 5 years ago #

    I want to do almost exactly the same thing as TDO-Mini-Forms.

    I want to completely replace the default WordPress new post page, "post-new.php", with my own one.

    I don't want to do it via XMLRPC because I want only logged-in users to be able to post to my site.

    I don't want logged in users to have to go to post-new.php or anywhere in my admin panel to post ... I basically want to layout 5 or 6 different fields that are required for a new post, say like:

    Title of Post
    URL to remote site
    Description of post
    Thumbnail upload
    tags for post
    categories for post

    I've searched for days but cannot find anywhere that'll teach me how to do this... to clarify, I know how to show the fields above, and I know how to call categories for users to select from, but where do I sent that information to get WordPress to treat it like a native new post?

    I'm assuming this all gets wrapped up in an array of some sort, instead of everything getting inserted in MySQL separately!

    Any help is appreciated!

  2. tianbo84
    Member
    Posted 5 years ago #

    There would be a couple ways, first you could use TDO forms plugin then use something like PHPexe and throw some php in the page with the form for allowing only certain users to see it (TDO also does this in the options).

    Also you could create a new page, create a form with your input fields you want, than have that form process a php file you make with the code in it. Start here for the proper codex to use in you php file.

    For example:

    $title = $_POST['title']; //from your form...
      $my_post = array();
      $my_post['post_title'] = $title;
      wp_insert_post( $my_post );

    Anywayz hopefully this helps.

  3. jtreminio
    Member
    Posted 5 years ago #

    This is exactly what I needed.

    Thanks a ton!

    wp_insert_post combined with add_post_meta solves all of my problems perfectly.

    It's awesome and you're awesome. Thanks :)

  4. e-sushi
    Member
    Posted 4 years ago #

    @jtreminio mind sharing your knowledge?

    I've been looking for exactly the same thing and a short hint to working code would just make my (and probable the community's) day.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags