The best place to ask WordPress questions is probably on WordPress Answers . Anyhoo, if you want to solve this without plugins, you need three things:
When you have these three parts in place, you can do the following in your page template:
<?php global $current_user; get_currentuserinfo(); $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $company = $_POST['company']; if (($firstname != '') && ($lastname != '') && ($company != '')) { <div id="page-<?php the_ID(); ?>"> <h2><?php the_title(); ?></h2> <div class="content"> <?php the_content() ?> </div> <form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post"> <div class="firstname"> <label for="firstname">First name:</label> <input name="firstname" id="firstname" value="<?php echo esc_attr($firstname) ?>"> </div> <div class="lastname"> <label for="lastname">Last name:</label> <input name="lastname" id="lastname" value="<?php echo esc_attr($lastname) ?>"> </div> <div class="company"> <label for="company">Company:</label> <input name="company" id="company" value="<?php echo esc_attr($company) ?>"> </div> </form> </div> <?php endwhile; endif; ?>
Now, when you want to get the material that you saved, you need to know whether this information is in the User object or in the metadata. To get the first and last name (registered user):
global $current_user; $firstname = $current_user->first_name; $lastname = $current_user->last_name;
To get the name of the company (registered user):
global $current_user; $company = get_usermeta($current_user->id, 'company');
This is the main point. There are still a lot of missing things, such as validation, error message output, handling errors that occur in the WordPress API, etc. There is also an important TODO that you have to take care of before the code works. The code should probably also be split into several files, but I hope this is enough to get you started.
source share