1) Create Front-End Profiles, Forms or Courses… 2) Smile.

1) Create Front-End Profiles, Forms or Courses… 2) Smile.

WordPress User Plugin \- Smiling Dog

Have you been looking for a WordPress user plugin that can enable your users to enter and update data from the front-end of your site? You can stop chasing your tail and start grinning now, ‘cuz the User Meta plugin has got you covered!

Download from WordPress.org | More Info at User-Meta.com

Let’s start by having a chew on one of the main features of the User Meta plugin, then see what other cool stuff we can do with it.

Update user profile info from the front-end

A lot of us don’t want our users in the back-end of our sites, but do want them to have access to some of the functionality. One of the easiest things you can accomplish with this WordPress user plugin is enabling your users to edit and update their profiles on the front-end of your site. This information is most often used to display author bios on posts and pages, but you can use this data anywhere and any way you like really.

Although there is a premium version of User Meta available with a bunch of extra field types and options, the freebie has teeth enough for most projects. The field types available in the free version of the plugin give you everything you need to create a front-end form for your users.

WordPress User Plugin \- Screenshot of User Meta default fields

Simply select the fields you need in the Fields Editor under the new User Meta menu item in your site’s admin area. Then set the options for each created field. You can define an unlimited number of each field type for several different needs or projects. Note the built-in password-strength meter that can be selected in the “Password” field.

WordPress User Plugin \- Screenshot of User Meta field editor

Once all your fields are set up, create a new form in the Forms Editor and drag the fields you need to your new form. Each field can be used in an unlimited number of forms. That’s right, unlike many other front-end form plugins, User Meta does not restrict fields to any single form. Once you’ve set them up, you can use them over and over again in different projects!

WordPress User Plugin \- Screenshot of User Meta form editor

Then add the appropriate shortcode to a page or post to display the profile form for your users (e.g. [user-meta type=’profile’ form=’your_form_name’] ).

WordPress User Plugin \- Screenshot of User Meta form

The information entered in your frontend profile form updates the user profile in your WordPress backend, as well as the info that is shown in the post author box (included in most themes).

WordPress User Plugin \- Screenshot of author box

There are several ways to display your forms or data

The User Meta plugin saves data to the wp_usermeta table. Plus, this WordPress user plugin can not only update the data in default fields in that table, it creates new field entries for each custom field you create. (The wp_usermeta table in your WordPress database is where all the data pertaining to individual users of your site is stored. That includes data such as ID, user_login, user_pass, user_nicename, user_email, etc.)

There are several ways that data from the wp_usermeta table can be called, entered, updated or otherwise manipulated:

  • As seen in the example above, custom forms that you create with User Meta can be easily inserted into any page or post with a simple shortcode.
  • You can call data from the wp_usermeta table in your theme templates by using default WordPress functions (e.g. get_userdata(), get_user_meta() or get_currentuserinfo() ).
  • Install another cool plugin – User Meta Shortcodes – to display data from individually specified fields via shortcodes in your pages and posts.
  • Or try the Shortcode Exec PHP plugin to build your own shortcode with the WordPress functions noted above, and use that in your pages or posts… with no template edits. (See also a write-up I did a while back on this plugin: Writing php code to your WordPress posts and pages the safe way)

Built-in WordPress functions to call your data

As noted above, you can easily use the data from the wp_usermeta table in your theme templates, or in custom shortcodes you build with the Shortcode Exec PHP plugin. There are several default WordPress functions you can use to do so, for example:

The functions get_userdata() or get_user_meta() can be used to display stuff for a specified user as in this example from the WordPress codex:

FREE EBOOK
Your step-by-step roadmap to a profitable web dev business. From landing more clients to scaling like crazy.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

FREE EBOOK
Plan, build, and launch your next WP site without a hitch. Our checklist makes the process easy and repeatable.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

<?php $user_info = get_userdata(1);
      $username = $user_info->user_login;
      $first_name = $user_info->first_name;
      $last_name = $user_info->last_name;
      echo "$first_name $last_name logs into her WordPress site with the user name of $username.";
?>

The above code added to your theme template would output something like this on your page:

Harriet Smith logs into her WordPress site with the user name of mrssmith.

If you need to display data pertaining to the currently logged-in user, use the get_currentuserinfo() function. Note that you need to call the $current_user global also. Again, here’s an example borrowed from the codex:

<?php global $current_user;
      get_currentuserinfo();

      echo 'Username: ' . $current_user->user_login . "\n";
      echo 'User email: ' . $current_user->user_email . "\n";
      echo 'User first name: ' . $current_user->user_firstname . "\n";
      echo 'User last name: ' . $current_user->user_lastname . "\n";
      echo 'User display name: ' . $current_user->display_name . "\n";
      echo 'User ID: ' . $current_user->ID . "\n";
?>

The code above would output something like this in your template:

Username: Zedd
User email: [email protected]
User first name: John
User last name: Doe
User display name: John Doe
User ID: 1

My favorite: get_currentuserinfo()

By using the get_currentuserinfo() function to call your custom User Meta fields inside some basic WordPress conditional tags, you can create just about anything you want with this WordPress user plugin. Here’s an example of how you can display a form with the logged-in user’s private information to the logged-in user only, and display an error message for everyone else:

<?php global $current_user;
      get_currentuserinfo();
            if(!is_user_logged_in()):
                  echo '<div id="message" class="error"><p>You do not have permission to view this private member information.</p></div>';
            else:
                  if (!$current_user->my-custom-user-meta-field-key == '') {
                  echo '<p>This user-meta value is:' . $current_user->my-custom-user-meta-field-key . '</p>';
                  }
                  if ($current_user->my-custom-user-meta-field-key == '') {
                  echo '<p>Please complete this field</p>';
                  echo do_shortcode('[user-meta type="profile" form="My User Meta Form"]');
                  }
            endif;
?>

I got really excited when I found this plugin! Here’s what happened next…

My excitement distracted me so much that it’s been several days since my last post here on WPMU.org (sorry boss!).

Kidding aside, I’ve used the User Meta plugin as one of the cornerstones to build a course consisting of a series of daily exercises designed to be completed by users over a period of 15 weeks. Each exercise is on its own WordPress page and comes with a form that can be toggled open to display “Private Notes”, and a select-box to mark the exercise as “Done” when it’s completed. (For this project, I used toggle shortcodes from the Shortcodes Ultimate plugin. For more, see also Cool WordPress shortcode plugins to snap your blog into style.)

WordPress User Plugin \- Screenshot of PReP exercise

A custom BuddyPress component (coded and added via bp-custom.php) then serves as a private area where logged-in users can keep track of exercises they have done, and those still to be done. Once a current week’s series of exercises have been completed, a “Weekly Summary” form can be toggled open. Only when that form is completed does the subsequent week’s series of exercises appear and become accessible.

WordPress User Plugin \- Screenshot of private PReP area

A sub-page in the private area serves to compile and display information the user enters in the Weekly Summaries once each week’s exercises are completed.

WordPress User Plugin \- Screenshot of PReP goals

The next thing I’ll be integrating into this project is a User Meta form in each row of the table illustrated above with a date-picker. That will enable users to set a deadline for each goal they set for themselves. Then it’s on to integrating a bit of drag-and-drop jQuery magic so users can re-order the table rows to keep their goals and deadlines in whatever order they wish. Loads of fun!

Once I’ve completed all the above, I’ll write up a nice tutorial on how to get it all done (and update this post with a link). Then you can create something amazing too! If you beat me to the punch, and build something cool before I post a tut, please brag about it in the comments below :-)

Here are those links again to this fabulous WordPress user plugin (is your mouth watering yet?)

Download from WordPress.org | More Info at User-Meta.com

Tags: