• anibabbar

    (@rockersofarena)


    Hello all !!

    Right now when we open a page with wp user frontend form, it asks to login.

    What i wanted was to ask for user login when a user click on submit button instead of load page.

    I accomplished this by removing conditions on wpuf-add-post.php

    at first i changed

    if ( is_user_logged_in() ) {
                $this->post_form( $post_type );
            } else {
                printf( __( "This page is restricted. Please %s to view this page.", 'wpuf' ), wp_loginout( get_permalink(), false ) );
            }

    to

    $this->post_form( $post_type );
            }

    and then changed submit button from this

    <li>
                                <label>&nbsp;</label>
                                <input class="wpuf_submit" type="submit" name="wpuf_new_post_submit" value="<?php echo esc_attr( wpuf_get_option( 'submit_label', 'wpuf_labels', 'Submit' ) ); ?>">
                                <input type="hidden" name="wpuf_post_type" value="<?php echo $post_type; ?>" />
                                <input type="hidden" name="wpuf_post_new_submit" value="yes" />
                            </li>

    to

    <?php if ( !is_user_logged_in() ) {
    
    		   printf( __( "please login to post", 'wpuf' ), wp_loginout( get_permalink(), false ) );
    		   ?>
    
    						<?php
            } else {
            ?>      <li>
                                <label>&nbsp;</label>
                                <input class="wpuf_submit" type="submit" name="wpuf_new_post_submit" value="<?php echo esc_attr( wpuf_get_option( 'submit_label', 'wpuf_labels', 'Submit' ) ); ?>">
                                <input type="hidden" name="wpuf_post_type" value="<?php echo $post_type; ?>" />
                                <input type="hidden" name="wpuf_post_new_submit" value="yes" />
                            </li>
         <?php   } ?>

    Now this thing is done properly !!

    I am able to sort this out easily, the problem is page is reloaded when user submits form and all fields are lost ??

    can anyone help me to save those fields somehow after page load or after login post is automatically published !!

    In Short – I wanted a user submitted form where user can fill the post and then login to site and content is posted on site.

    https://www.ads-software.com/plugins/wp-user-frontend/

  • The topic ‘Wanted to display login form when user clicks on submit button but got a problem’ is closed to new replies.