PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Can a user create an account and submit post with the same form?

  1. Lea Cohen
    Member

    I have a request from the client, that the form be used both as a registration form, and a form for post submissions. Therefore, there will be fields for registration, and fields for posts, and the form will have to create the user according to the registration fields (unless the user already exists) , and then create the post according to the post fields, and attribute the post to that created user, so that when that user logs in to the admin, he will see only the posts that he submitted (the same user should be able to submit the form multiple times, for multiple posts).

    How can I do this?

    Posted 12 years ago on Sunday June 5, 2011 | Permalink
  2. Lea Cohen
    Member

    Addition: I see that what I requested can be done. However, if the same user wants to fill out the form multiple times, it's always treated as a registration form, and shows an error that username already exists. Is there any way to make it work like a login form if the user already exists?

    Posted 12 years ago on Sunday June 5, 2011 | Permalink
  3. A user can be registered and create a post with the same form. However that form is always going to try and create a user.

    You would have to point already logged in users to a different form that only creates a post. Currently the User Registration Add-On doesn't support conditionally creating the user. It is a feature we plan on adding... the ability to hide the user creation fields if the user is already logged in.

    But currently the only way to do this is to have 2 different forms, one that registers the user and creates a post and one that just creates the post.

    Posted 12 years ago on Sunday June 5, 2011 | Permalink
  4. Lea Cohen
    Member

    Thank you so much for your reply.

    What about login - if I don't want the use to log in through the admin part of Wordpress, can I have him log in through a form (the same one that creates, or a separate one)?

    Posted 12 years ago on Monday June 6, 2011 | Permalink
  5. Gravity Forms currently can't login users and can't be used as a login form. Only a registration form or lead capture form.

    Posted 12 years ago on Monday June 6, 2011 | Permalink
  6. you could login users with a form and/or create users

    $user_pass = rand_string(6);
    			wp_insert_user( array(
    				'user_pass' => $user_pass,
    				'user_login' => $user_email,
    				'user_email' => $user_email,
    				'role' => 'contributor' )) ;
    			$creds['user_login'] = $user_email;
    			$creds['user_password'] = $user_pass;
    			$creds['remember'] = true;
    			wp_set_current_user( wp_signon( $creds, false )->ID);
    Posted 12 years ago on Friday June 24, 2011 | Permalink

This topic has been resolved and has been closed to new replies.