Forums

registration and post submit on the same page ? (2 posts)

  1. Malaiac
    Member
    Posted 3 years ago #

    Hiho,
    I'd like to allow visitors to register AND submit a story on the same page.
    Right now, they have to
    1. register
    2. check their email
    3. login
    4. submit a story

    I'd like to have :
    1. on the same page, fill email information, submit a story (maybe choose their password)
    2. (maybe) confirm their story by clicking a link in their email (to prevent spam)

    Any idea of a plugin I could use, or a simple hack to do that ?

    (I need that feature for a WP-as-a-directory plugin)

  2. Malaiac
    Member
    Posted 3 years ago #

    I finally worked around with that code :

    // New user autologin
      // user unknwown, let's create it, log him in, and allow him to submit his site
      // wp-login is included with output buffering to define functions without output
      ob_start();
      include_once(ABSPATH.'/wp-login.php'); // for function definition (register_new_user() )
      include_once(ABSPATH.'/wp-includes/registration.php'); // for function definition (validate_username() )
      ob_clean(); 
    
    	$errors = register_new_user($username,$useremail);
      if ( is_wp_error($errors) ) {
    	wp_redirect('wp-login.php?action=register');
    	exit();
      }
      else $user_id = $errors;
    
      // auto login
      $user = new WP_User($user_id);
      wp_set_auth_cookie($user_id, true);

Topic Closed

This topic has been closed to new replies.

About this Topic