Shortcodes

Shortcodes List

Profile Builder 2.0 comes with a set of shortcodes you can use right away:

  • [wppb-login] – displays the front-end login form
  • [wppb-logout] – displays the front-end logout text and link
  • [wppb-register] – displays the front-end registration form
  • [wppb-edit-profile] – displays the edit-profile form
  • [wppb-recover-password] – adds a front-end password recovery form
  • [wppb-list-users] – displays the front-end user listing
    * This shortcode will work only for the PRO version, when the the User Listing add-on is activated.
Shortcodes work only on pages created by users with administrator capabilities. This is to prevent users who can post but are not admins, from creating shortcodes that register administrators, thus gaining full access to the site.

Creating a Front-end Login page

  • Start by creating a new page for your website, by going to Pages->Add New
  • Give it an intuitive name like Login (or something similar)
  • Add the [wppb-login] shortcode
  • Publish the page and you’re done

wppb-login

Redirect users after Login

Profile Builder makes it really easy to redirect users after login to any URL you desire, by using the “redirect_url” shortcode argument:

[wppb-login redirect_url="www.yoursite.com"]

Note: The redirect will NOT work if it’s pointing to an outside URL, it needs to point to a page on your site.

Add Register and Lost Password links below the Login form

You can add a “Register” and “Lost your password?” link below the Login form using the following shortcode arguments:

[wppb-login register_url="www.yoursite.com" lostpassword_url="www.yoursite.com"]

login-shortcode-register-lostpass

Creating a Front-end Log out text/link

The [wppb-logout] shortcode allows you to display a logout text and link in the front-end, as well as redirect your users after they log out.

logout-shortcode

You can also use one or more of the available shortcode parameters, like below:

[wppb-logout text="You are currently logged in as {{meta_user_name}}. " redirect_url="http://www.yoursite.com/desired-link" link_text="Log out »"]
  • text – the intro text to display, where you can also use one of the following available tags: {{meta_user_name}}, {{meta_first_name}}, {{meta_last_name}}, {{meta_display_name}}
  • redirect_url – the desired link from your own website to redirect to after logout (defaults to current page)
  • link_text – the text for the log out link

Note: The logout shortcode requires at least Profile Builder version 2.0.9.

Creating a Front-end Register page

  • Create a new page called Register (or something similar)
  • Add the [wppb-register] shortcode
  • Hit publish and you’ll be prompted with a registration form in the front-end

wppb-register

Allow users to register via Profile Builder

In order for users to be able to register for your website, you first must enable user registration.

For this, in the WordPress admin interface, go to the Settings -> General tab, and under Membership make sure to check “Anyone can register”.

anyone-can-register
Save changes and your website will now allow user registration.

Register users with a specific role

You can allow users to be assigned a specific user role (e.g. editor, author etc.) on registration by using the role=”desired-role” argument in the register shortcode.

E.g. [wppb-register role="editor"]

The user-role argument from the short-code must be a valid (existing) role in the database, else the role will revert back to the default WordPress registration role (“Subscriber”) for security reasons.

Redirect users after Registration

Profile Builder makes it really easy to redirect users after registration to any URL you desire, by using the “redirect_url” shortcode argument:

[wppb-register redirect_url="www.yoursite.com"]

Note: The redirect will NOT work if it’s pointing to an outside URL, it needs to point to a page on your site.

Creating a Front-end Edit Profile page

You can allow users to edit their profile information in the front-end by using the [wppb-edit-profile] shortcode.

  • Create a new page called Edit Profile(or something similar)
  • Add the [wppb-edit-profile] shortcode
  • Publish the page and you’ll be prompted with an edit profile form in the front-end

wppb-edit-profile

Redirect users after Edit Profile

Profile Builder makes it really easy to redirect users after they edit their profile to any URL you desire, by using the “redirect_url” shortcode argument:

[wppb-edit-profile redirect_url="www.yoursite.com"]

Note: The redirect will NOT work if it’s pointing to an outside URL, it needs to point to a page on your site.

Creating a Recover Password page

You can easily create a front-end password recovery form by using the [wppb-recover-password] shortcode.

wppb-recover-password

  • Create a new page called Recover Password(or something similar)
  • Add the [wppb-recover-password] shortcode
  • Publish the page and you’ll have a front-end recover password form

Creating a Front-end User Listing

Displaying your website users in the front-end can be achieved using the User Listing shortcode: [wppb-list-users]

wppb-list-users

  • Create a new page called User Listing(or something intuitive like Member Directory)
  • Add the [wppb-list-users] shortcode
  • Publish the page and you’ll have a front-end listing of your website users

19-pb2.0-user-listing
* The User Listing module is available only in the PRO version of Profile Builder 2.0. You will have to enable this module in order for the User Listing shortcode to work.

The User Listing module offers many options to customize and control the listing of your users. Make sure to check out the User Listing documentation page.

List users with a certain meta_key and meta_value combination

You can list only the users with a certain extra-field meta-name (ex: “car”) and value (ex: “family”) combination by using the following shortcode:
[wppb-list-users meta_key="car" meta_value="family"]

This way the user listing will contain only the users which own a family car.

Note: if you want to use this method with a checkbox, you need to put a trailing comma after the meta_value value.

Include or exclude users from a list

There are certain situations where you would like to display only a handful of users. You can do this with the following shortcode: [wppb-list-users include="1,2,3,4"]. The numbers in the include attribute are the IDs of the users you wish to display.

You can also exclude users from certain lists. With the shortcode: [wppb-list-users exclude="1,2"] all users will be displayed, with the exception of the users with the IDs 1 and 2.

Display Single User-Profile using shortcode

You might want to display a specific user profile on a page, post or widget. This is possible using the following shortcode: [wppb-list-users single id="1"]. Where id contains the id of the user which you want to display the profile for.

You can also not specify the id parameter to display the profile of the current logged in user: [wppb-list-users single].