Formidable Registration Goodies

  1. Download latest version at http://formidablepro.com/formidable-add-on-downloads/
    Important: Versions 1.0rc4+ require Formidable v1.6+
  2. In your WordPress admin, go to “Plugins” -> “Add New” and click the “Upload” link at the top of the page.
  3. Click the “Browse” button and select the zip file you just downloaded.
  4. Go the the “Plugins” page, find “Formidable Registration” and click “Activate”.
  5. Go to “Formidable” -> “Forms” and click “edit” for the form you would like to use for user registration or editing profiles.
  6. Go to “Registration Options” at the bottom of the page and set your options. Registration Options
  7. Click the “Update” button at the bottom of the page.

Add a login form

The easiest way to add a login form is to use the “Login Form” widget. If you don’t want this to display on all pages, install ourDisplay Widgets plugin for additional settings.

If you would like to create a separate login page, you can add a shortcode to your page.

frm-login Shortcode

[frm-login]

Shortcode options:
remember – Show the checkbox to remember your users. Defaults to show it. Hide with remember=0
label_username – Change the label of the username box. label_username=”Username”
label_password – Change the label of the password field. label_password=”Password”
label_remember – Change the label on the remember me checkbox. label_remember=”Remember Me”
label_log_in – Change the label of the login button. label_log_in=”Login”
slide – Set your form to be hidden and require a click to show it. slide=1
style – Use Formidable styling on your form. Disable styling with style=0
layout – Show the fields either horizontally or vertically. layout=h or layout=v
value_username – Insert a default value into the username field. value_username=”Username”
value_remember – Check the remember me checkbox be default. value_remember=1

Customize the HTML ids:
form_id
id_username
id_password
id_remember
id_submit

Password change form

  • Set your form up with the registration add-on.
  • Include an email field selected as the user email in your form. Other than that, none of the fields are required. If you don’t want this field shown, add [admin_email] as the dynamic default value and check the “admin only” box.
  • To allow the user to change the password, check these boxes in the form settings: “Allow only one entry for each logged-in user” and “allow logged in users to edit previous responses.”
    You find find more on editing here.

Read more about adding custom code.

Link an upload field to user avatars

Add this code to a new plugin or your theme functions.php. The only line that needs to be changed is line #3 unless you use “frm_avatar” as the user meta name in your registration settings: $user_meta_name = “frm_avatar”;

add_filter( 'get_avatar', 'get_frm_avatar', 10, 5 );
function get_frm_avatar( $avatar = '', $id_or_email, $size = '96', $default = '', $alt = false ){
  $user_meta_name = 'frm_avatar'; //change frm_avatar to whatever user meta name you have given the upload field in your registration settings
  if ( is_numeric($id_or_email) ){
    $user_id = (int) $id_or_email;
  }elseif ( is_string($id_or_email) ){
    if ( $user = get_user_by_email( $id_or_email ) )
      $user_id = $user->ID;	
  }elseif ( is_object($id_or_email) && !empty($id_or_email->user_id) ){
      $user_id = (int) $id_or_email->user_id;
  }

  if ( isset($user_id) ){
    $avatar_id = get_user_meta( $user_id, $user_meta_name, true );
    $local_avatars = FrmProFieldsHelper::get_media_from_id($avatar_id, $size);
  }

  if ( !isset($local_avatars) || empty($local_avatars) ){
    if ( !empty($avatar) )  // if called by filter
      return $avatar;

    remove_filter( 'get_avatar', 'get_frm_avatar' );
    $avatar = get_avatar( $id_or_email, $size, $default );
    add_filter( 'get_avatar', 'get_frm_avatar', 10, 5 );
    return $avatar;
  }

  if ( !is_numeric($size) ) // ensure valid size
    $size = '96';

  if ( empty($alt) )
    $alt = get_the_author_meta( 'display_name', $user_id );

  $author_class = is_author( $user_id ) ? ' current-author' : '' ;
  $avatar = "<img alt='" . esc_attr($alt) . "' src='" . $local_avatars . "' class='avatar avatar-{$size}{$author_class} photo' height='{$size}' width='{$size}' />";

  return $avatar;
}

Stop the registration email

add_filter('frm_send_new_user_notification', 'frm_stop_user_notification');
function frm_stop_user_notification($send){
  return false;
}

Set the user role

Sometimes the user role may be different for different options chosen in your form. Here’s an example of setting the role depending on what role is chosen in the form.

add_filter('frmreg_new_role', 'frmreg_new_role', 10, 2);
function frmreg_new_role($role, $atts){
  extract($atts);
  if($form->id == 5){
    if($_POST['item_meta'][125] == 'Author') //change 125 to the ID of your field and 'Author' to the value of your radio button
      $role = 'author';
  }
  return $role;
}

User Examples

http://demo.formidablepro.com/directory/register/

 

Revisions

Tags: , , ,

No comments yet.

Leave a Reply