Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This is form on my first page. I have to manage if user is not logged in, in that Case after submit form action is Login Page.

<?php/** Template Name: Form */ 
get_header(); ?>

<form id="new_post" <?php do_action('post_edit_form_tag'); ?> name="new_post" method="post" action="<?php if ( is_user_logged_in() ) { } else { echo 'http://localhost/manage/login'; } ?>">
<p><label for="title">Project Title</label><br />
<input type="text" id="title" value=""  name="title" /></p>
<p><label for="Category">Category:</label><br />
<?php wp_dropdown_categories('type=post&show_count=0&selected=-1&hierarchical=1&depth=1&hide_empty=0&exclude=0&show_option_none=Select Category&taxonomy=category');?></p>
<p><label for="description">Project Description</label><br/>
<textarea id="description"  name="description" ></textarea></p>
<p><label for="post_date">submit date:</label></br>
<input type="text" value="" tabindex="5" size="16" name="post_date" id="post_date" /></p>
<p align="right"><input type="submit" value="Publish" tabindex="6" id="submit" name="submit" /></p>
<input type="hidden" name="action" value="new_post" />
<?php wp_nonce_field( 'new-post' ); ?></form>

<?php get_footer(); ?>

After Submit this form i am sending POST value on LOGIN PAge where I want to SAVE Post With UserID after user logged In . This PAGE Code :

<?php
/**
 * * Template Name: Login Page
*/
get_header(); ?>

<?Php
// Values Comin From 1st Page
$title =  $_POST['title'];
$description = $_POST['description'];
$category = $_POST['cat'];
$date = $_POST['post_date'];

if (isset ($_POST['login'])) {
    $new_post = array(
                         'post_author'    => LOGGED IN USERID,
                         'post_title'    => $title,
                         'post_content'  => $description,
                         'post_status'   => 'publish',
                         'post_type' => 'post' 
                        ); 
                        //save the new post
                          $pid = wp_insert_post($new_post);

                        add_post_meta( $pid, 'category', $category , true );
                        add_post_meta( $pid, 'date', $date, true );    
    }
?>

        <form id="login" action="login" method="post" name="new_post">
        <h1>Site Login</h1>
        <p class="status"></p>
        <label for="username">Username</label>
        <input id="username" type="text" name="username">
        <label for="password">Password</label>
        <input id="password" type="password" name="password">
        <input class="submit_button" type="submit" value="Login" name="login">  
        <?php wp_nonce_field( 'ajax-login-nonce', 'security' ); ?>
        <input type="hidden" name="action" value="new_post" />
        <?php wp_nonce_field( 'new-post' ); ?>
    </form>
<?php get_footer(); ?>

So This is Code which i am using.

share|improve this question
add comment

1 Answer

Just inspect the $_POST values on your login page.

add_action( 'login_head', 'wpse_98289_custom_form' );
function wpse_98289_custom_form()
{
    var_dump( $_POST );
}

You can there search for the values that you assigned as name/id attributes and then start populating your custom/additional fields in your login form.

share|improve this answer
    
Hi Kaiser, I am Posting the Data on Login Page at 1st Page. after this i am doing Login on 2nd Page. I have to Save The Form Value As A POST in DataBase Also Save the UserID with this Post. so when we are sending the form value on 2nd Page How we Perform Login And SAVE POST with Loggedin UserId Together. –  mit May 5 '13 at 7:41
    
@mit Why are you asking another question in the comments? This answer is the answer to your question. If you got another question: Please go and open another one. –  kaiser May 5 '13 at 15:53
    
Hey Kaisar, Can You Please Describe this with an Example. So it will be clear to me. –  mit May 6 '13 at 10:14
    
@mit First, my name is kaiser, not Kaisar. Second: What shall I describe to you? Third, as @brasofilo mentioned in the comment on your question: Edit your question and show us your code. –  kaiser May 6 '13 at 10:15
    
Hey kaiser, Now i have Wrote Down the Code Which I am Using. –  mit May 7 '13 at 9:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.