Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Give the user a role choice and tailor their profile area WordPress

  • SOLVED

I am developing a fitness training directory where I have three user groups:

1. Client - someone who has signed up with minimal information (just username and email) OR have done one click signup using facebook connect. For the simple use signup I am using UPME (User Profiles Made Easy) to bring the registration and profiles to the front end. These will have the OPTION of upgrading their membership to become a trainer if they wish.

2. Trainer - these are going to have a extensive user profile area where we can get all sorts of custom meta from (I am using a gravity form for this).

3. Trainer Pro - they pay extra money on signup and require giving a different role for access to additional features.


I am keen for every use to have a very fast registration ability (FBConnect or username and email) and then let them fill out their profile at their convenience.

I want trainers to click a link "I Want to Become A Trainer" this is the gravity form with the paypal subscription where they have to fill out much morning compulsory information.

When they have paid they will be given a new ROLE depending on the amount paid:
<strong>1. HOW CAN I GIVE A DIFFERENT ROLE TO THE TWO DIFFERENT PRICE POINTS??</strong>

and

<strong>2. HOW CAN I GIVE THEM A UPDATABLE PROFILE AREA ONLY VISIBLE TO THEIR ROLE USING GRAVITY FORMS.
</strong>
<strong>3. HOW CAN I IMPLEMENT A FBCONNECT LOGIN BUTTON WITH UPME</strong>

I will need some code examples and should anyone wish to work with me on this project I have some funds for developer consultation.

many thanks

Answers (2)

2013-08-17

Sabby Sam answers:

Hi Taylosuk,

Making a such site is little complicated but if you are programmer then it could be easy for you.
If you are programmer then email me the same requirement I will guide you step by step ? My email ID is [email protected]
I have created similar site with similar functionality type, I can help you.
Let me know How I can help you?


Sabby Sam comments:

http://pastebin.com/pFHCfRsh#


PASTEBIN | #1 paste tool since 2002
create new pastetoolsapiarchivefaq
PASTEBIN Search...
create new paste trending pastes
sign uploginmy alertsmy settingsmy profile
Don't like ads? PRO users don't see any ads ;-)
Public Pastes
Untitled
3 sec ago
Error Log report
3 sec ago
Untitled
8 sec ago
Untitled
9 sec ago
Untitled
1 min ago
Korrektur
12 sec ago
Dans la peau d'un autre ..
14 sec ago
Untitled
14 sec ago


0
0
Guest
Saving custom fields
BY: FRAGGY ON MAY 22ND, 2012 | SYNTAX: PHP | SIZE: 9.06 KB | HITS: 18 | EXPIRES: NEVER
DOWNLOAD | RAW | EMBED | REPORT ABUSE | PRINT


//checking user role in profile page
add_action( 'show_user_profile', 'user_fields_for_admin', 10);
add_action( 'edit_user_profile', 'user_fields_for_admin', 10);
function user_fields_for_admin( $user ){
//Setting up variables to hold the registration data
$selected_register = esc_attr(get_the_author_meta( 'registered_as', $user->ID ));
$selected = get_the_author_meta( 'unit_type', $user->ID );
$selected_unit_number = esc_attr(get_the_author_meta( 'unit_number', $user->ID) );
$first_name = esc_attr(get_the_author_meta( 'first_name', $user->ID));
$last_name = esc_attr(get_the_author_meta( 'last_name', $user->ID));
$owner1_address = esc_attr(get_the_author_meta( 'owner1_address', $user->ID));
$owner1_tel_day = esc_attr(get_the_author_meta( 'owner1_tel_day', $user->ID));
$owner1_tel_night = esc_attr(get_the_author_meta( 'owner1_tel_night', $user->ID));
$emergency_contact_name = esc_attr(get_the_author_meta( 'emergency_contact_name', $user->ID));
$emergency_contact_tel_day = esc_attr(get_the_author_meta( 'emergency_contact_tel_day', $user->ID));
$emergency_contact_tel_night = esc_attr(get_the_author_meta( 'emergency_contact_tel_night', $user->ID));

echo '<h2 class="imperial-title">Registration Info</h2>';
echo '<table class="form-table registered-as-table"><tbody>
<tr>';
echo '<th>Registered as</th>';
echo '<td>';
echo '<select name="registered_as" id="registered_as">';
echo '<option value=""'; echo ($selected_register == "")? 'selected="selected"' : ''; echo '></option>';
echo '<option value="Owner"'; echo ($selected_register == "Owner")? 'selected="selected"' : ''; echo '>Owner</option>';
echo '<option value="Tenant/Occupier"'; echo ($selected_register == "Tenant/Occupier")? 'selected="selected"' : ''; echo '>Tenant/Occupier</option>';
echo '<option value="Board"'; echo ($selected_register == "Board")? 'selected="selected"' : ''; echo '>Board Member</option>';
echo '<option value="Contractor"'; echo ($selected_register == "Contractor")? 'selected="selected"' : ''; echo '>Contractor</option>';
echo '<option value="Condo Management Company"'; echo ($selected_register == "Condo Management Company")? 'selected="selected"' : ''; echo '>Condo Management Company</option>';
echo '</select></td>';
echo '</tr>';
echo '</tbody></table>';
switch ($user->roles[0]) {
//THIS IS FOR PENDING USERS

case 'pending':
//If PENDING and OWNER show these fields. Note that these are only a selection of the person registering so that they can be

if ($selected_register == "Owner"){
echo '<h2>Pending Owner Registration Information</h2>';
//SELECT BOX FOR REGISTERED AS
echo '<div class="pending-user error"><p><strong>THIS USER IS PENDING PLEASE UPDATE THEIR ROLE</strong></p></div>';

echo '<p>The following is just the name and contact details of people registering as owners. The rest will be shown once you have changed their role to "Owner"</p>';
//OWNER DETAILS
echo '<h3>Owner Details</h3>';
echo '<table class="form-table"><tbody><tr>';
//FIRST NAME
echo '<tr><th>First Name</th>';
echo '<td><input type="text" name="first_name" id="first_name1" value="'; echo $first_name; echo '" class="regular-text" /></td>';
echo '</tr>';
//LAST NAME
echo '<tr><th>Last Name</th>';
echo '<td><input type="text" name="last_name" id="last_name1" value="'; echo $last_name; echo '" class="regular-text" /></td>';
echo '</tr>';
//ADDRESS
echo '<tr><th>Owner Address</th>';
echo '<td><input style="width:400px;" type="text" name="owner1_address" id="owner1_address" value="'; echo $owner1_address; echo '" class="regular-text" /></td>';
echo '</tr>';
//TELEPHONE
echo '<tr><th>Owner Telephone</th>';
echo '<td><input type="text" name="owner1_tel_day" id="owner1_tel_day" value="'; echo $owner1_tel_day; echo '" class="regular-text" /></td>';
echo '</tr>'; echo '</tbody></table>';

//UNIT DETAILS
echo '<h3>Unit Details</h3>';
echo '<table class="form-table"><tbody><tr>';
//UNIT TYPE
echo '<th>Unit Type</th>';
echo '<td>';
echo '<select name="unit_type" id="unit_type">';
echo '<option value=""'; echo ($selected == "")? 'selected="selected"' : ''; echo '></option>';
echo '<option value="Residential"'; echo ($selected == "Residential")? 'selected="selected"' : ''; echo '>Residential</option>';
echo '<option value="Commercial"'; echo ($selected == "Commercial")? 'selected="selected"' : ''; echo '>Commercial</option>';
echo '</select></td></tr>';
//UNIT NUMBER
echo '<tr><th>Unit Number</th>';
echo '<td><input type="text" name="unit_number" id="unit_number" value="'; echo $selected_unit_number; echo '" class="regular-text" /></td>';
echo '</tr>';
echo '</tbody></table>';
}
//IF REGISTERED AS BOARD SHOW BOARD FIELDS
elseif ($selected_register == "Board") {
echo 'Board fields will go in here';
}
break;

//THIS IS OWNERS
case 'owner':
//OWNER DETAILS
echo '<h3>Owner Details</h3>';
echo '<table class="form-table"><tbody><tr>';
//FIRST NAME
echo '<tr><th>First Name</th>';
echo '<td><input type="text" name="first_name" id="first_name1" value="'; echo $first_name; echo '" class="regular-text" /></td>';
echo '</tr>';
//LAST NAME
echo '<tr><th>Last Name</th>';
echo '<td><input type="text" name="last_name" id="last_name1" value="'; echo $last_name; echo '" class="regular-text" /></td>';
echo '</tr>';
//ADDRESS
echo '<tr><th>Owner Address</th>';
echo '<td><input style="width:400px;" type="text" name="owner1_address" id="owner1_address" value="'; echo $owner1_address; echo '" class="regular-text" /></td>';
echo '</tr>';
//TELEPHONE DAY
echo '<tr><th>Owner Telephone - Day</th>';
echo '<td><input type="text" name="owner1_tel_day" id="owner1_tel_day" value="'; echo $owner1_tel_day; echo '" class="regular-text" /></td>';
echo '</tr>';
//TELEPHONE NIGHT
echo '<tr><th>Owner Telephone - Night</th>';
echo '<td><input type="text" name="owner1_tel_night" id="owner1_tel_night" value="'; echo $owner1_tel_night; echo '" class="regular-text" /></td>';
echo '</tr>';
//EMERGENCY CONTACT
echo '<tr><th>Emergency Contact</th>';
echo '<td><input type="text" name="emergency_contact_name" id="emergency_contact_name" value="'; echo $emergency_contact_name; echo '" class="regular-text" /></td>';
echo '</tr>';
//EMERGENCY CONTACT TEL DAY
echo '<tr><th>Emergency Contact Telephone - Day</th>';
echo '<td><input type="text" name="emergency_contact_tel_day" id="emergency_contact_tel_day" value="'; echo $emergency_contact_tel_day; echo '" class="regular-text" /></td>';
echo '</tr>';
//EMERGENCY CONTACT TEL NIGHT
echo '<tr><th>Emergency Contact Telephone - Night</th>';
echo '<td><input type="text" name="emergency_contact_tel_night" id="emergency_contact_tel_night" value="'; echo $emergency_contact_tel_night; echo '" class="regular-text" /></td>';
echo '</tr>';

echo '</tbody></table>';

//UNIT DETAILS
echo '<h3>Unit Details</h3>';
echo '<table class="form-table"><tbody><tr>';
//UNIT TYPE
echo '<th>Unit Type</th>';
echo '<td>';
echo '<select name="unit_type" id="unit_type">';
echo '<option value=""'; echo ($selected == "")? 'selected="selected"' : ''; echo '></option>';
echo '<option value="Residential"'; echo ($selected == "Residential")? 'selected="selected"' : ''; echo '>Residential</option>';
echo '<option value="Commercial"'; echo ($selected == "Commercial")? 'selected="selected"' : ''; echo '>Commercial</option>';
echo '</select></td></tr>';
//UNIT NUMBER
echo '<tr><th>Unit Number</th>';
echo '<td><input type="text" name="unit_number" id="unit_number" value="'; echo $selected_unit_number; echo '" class="regular-text" /></td>';
echo '</tr>';
echo '</tbody></table>';
break;
}
}



//saving the user fields
add_action( 'personal_options_update', 'save_user_fields' );
add_action( 'edit_user_profile_update', 'save_user_fields' );

function save_user_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
update_usermeta( $user_id, 'unit_type', $_POST['unit_type'] );
update_usermeta( $user_id, 'registered_as', $_POST['registered_as'] );
update_usermeta( $user_id, 'date_registered', $_POST['date_registered'] );
update_usermeta( $user_id, 'unit_number', $_POST['unit_number'] );
update_usermeta( $user_id, 'first_name', $_POST['first_name'] );
update_usermeta( $user_id, 'last_name', $_POST['last_name'] );
update_usermeta( $user_id, 'owner1_address', $_POST['owner1_address'] );
update_usermeta( $user_id, 'owner1_tel_day', $_POST['owner1_tel_day'] );
update_usermeta( $user_id, 'owner1_tel_night', $_POST['owner1_tel_night'] );
update_usermeta( $user_id, 'emergency_contact_name', $_POST['emergency_contact_name'] );
update_usermeta( $user_id, 'emergency_contact_tel_day', $_POST['emergency_contact_tel_day'] );
update_usermeta( $user_id, 'emergency_contact_tel_night', $_POST['emergency_contact_tel_night'] );
}


taylorsuk comments:

This has helped me loads, easier to use functions.php rather than the template file that I was planning on using.
cheers


taylorsuk comments:

Cannot edit my reply (admin there is a error in your site...)

however my praise was directed and thanking Sabby Sam.

Many thanks

2013-08-17

Gabriel Reguly answers:

Hi taylorsuk,

1. I assume you are using PayPal addon for Gravity Forms, correct?

You can add a form field (select) where you ask them the value to be paid and then use that info to know which role they choose.

Gravity Forms site has some code examples.

2. Why use Gravity Forms for this, just add some custom code to user profile page.

[[LINK href="http://www.onextrapixel.com/2012/11/14/powerful-ways-to-customize-wordpress-user-profiles/"]]http://www.onextrapixel.com/2012/11/14/powerful-ways-to-customize-wordpress-user-profiles/[[/LINK]]

Or maybe try this plugin: [[LINK href="http://wordpress.org/plugins/user-meta/"]]http://wordpress.org/plugins/user-meta/[[/LINK]]

3. I would recommend [[LINK href="http://www.oneall.com/"]]http://www.oneall.com/[[/LINK]] for easy registration, they have a free plan.


If you could tell us your time frame and budget would be nice, sharing this info is a good way to know your expectations.

Regards,
Gabriel


taylorsuk comments:

I have sorted the login / social login and the role change using two forms and the role change upon payment...

My issue with still with this updateable profile area... I have been using Theme My Login for changes to the profile area on the frontend however please see [[LINK href="http://www.daveallworthy.com/nitg/trainer-set-up-PROFILE.html"]]here[[/LINK]] for an example of the complexity of the profile area - it has MANY MANY custom fields that have been created and mapped using Gravity Forms.

I need to be able to conditionally show the correct updatable profile area there is a example of this [[LINK href="http://wordpress.org/support/topic/plugin-theme-my-login-hide-profile-fields-from-theme-my-login"]]here[[/LINK]] however to create this file from scratch is a hell of a lot of work... Also when I try the conditional statement it makes the profile area fail...

here is a example of the profile-form.php file

<?php
/*
If you would like to edit this file, copy it to your current theme's directory and edit it there.
Theme My Login will always look in your theme's directory first, before using this default template.
*/
?>
<div class="login profile" id="theme-my-login<?php $template->the_instance(); ?>">
<?php $template->the_action_template_message( 'profile' ); ?>
<?php $template->the_errors(); ?>
<form id="your-profile" action="<?php $template->the_action_url( 'profile' ); ?>" method="post">
<?php wp_nonce_field( 'update-user_' . $current_user->ID ); ?>
<p>
<input type="hidden" name="from" value="profile" />
<input type="hidden" name="checkuser_id" value="<?php echo $current_user->ID; ?>" />
</p>

<?php if ( has_action( 'personal_options' ) ) : ?>

<h3><?php _e( 'Personal Options' ); ?></h3>

<table class="form-table">
<?php do_action( 'personal_options', $profileuser ); ?>
</table>

<?php endif; ?>

<?php do_action( 'profile_personal_options', $profileuser ); ?>

<h3><?php _e( 'Name' ); ?></h3>

<table class="form-table">
<tr>
<th><label for="user_login"><?php _e( 'Username' ); ?></label></th>
<td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr( $profileuser->user_login ); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e( 'Your username cannot be changed.', 'theme-my-login' ); ?></span></td>
</tr>

<tr>
<th><label for="user_login"><?php _e( 'Gender' ); ?></label></th>
<td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr( $profileuser->gender ); ?>" class="regular-text" /></td>
</tr>

<tr>
<th><label for="first_name"><?php _e( 'First Name' ); ?></label></th>
<td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profileuser->first_name ); ?>" class="regular-text" /></td>
</tr>

<tr>
<th><label for="last_name"><?php _e( 'Last Name' ); ?></label></th>
<td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profileuser->last_name ); ?>" class="regular-text" /></td>
</tr>

<tr>
<th><label for="nickname"><?php _e( 'Nickname' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
<td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ); ?>" class="regular-text" /></td>
</tr>

<tr>
<th><label for="display_name"><?php _e( 'Display name publicly as' ); ?></label></th>
<td>
<select name="display_name" id="display_name">
<?php
$public_display = array();
$public_display['display_nickname'] = $profileuser->nickname;
$public_display['display_username'] = $profileuser->user_login;

if ( ! empty( $profileuser->first_name ) )
$public_display['display_firstname'] = $profileuser->first_name;

if ( ! empty( $profileuser->last_name ) )
$public_display['display_lastname'] = $profileuser->last_name;

if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
$public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
$public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
}

if ( ! in_array( $profileuser->display_name, $public_display ) )// Only add this if it isn't duplicated elsewhere
$public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;

$public_display = array_map( 'trim', $public_display );
$public_display = array_unique( $public_display );

foreach ( $public_display as $id => $item ) {
?>
<option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
<?php
}
?>
</select>
</td>
</tr>
</table>



<h3><?php _e( 'Contact Info' ); ?></h3>

<table class="form-table">
<tr>
<th><label for="email"><?php _e( 'E-mail' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
<td><input type="text" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ); ?>" class="regular-text" /></td>
</tr>

<tr>
<th><label for="url"><?php _e( 'Website' ); ?></label></th>
<td><input type="text" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ); ?>" class="regular-text code" /></td>
</tr>

<?php
foreach ( _wp_get_user_contactmethods() as $name => $desc ) {
?>
<tr>
<th><label for="<?php echo $name; ?>"><?php echo apply_filters( 'user_'.$name.'_label', $desc ); ?></label></th>
<td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td>
</tr>
<?php
}
?>
</table>

<h3><?php _e( 'About Yourself' ); ?></h3>

<table class="form-table">
<tr>
<th><label for="description"><?php _e( 'Biographical Info' ); ?></label></th>
<td><textarea name="description" id="description" rows="5" cols="30"><?php echo esc_html( $profileuser->description ); ?></textarea><br />
<span class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.' ); ?></span></td>
</tr>

<?php
$show_password_fields = apply_filters( 'show_password_fields', true, $profileuser );
if ( $show_password_fields ) :
?>
<tr id="password">
<th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
<td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <span class="description"><?php _e( 'If you would like to change the password type a new one. Otherwise leave this blank.' ); ?></span><br />
<input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e( 'Type your new password again.' ); ?></span><br />
<div id="pass-strength-result"><?php _e( 'Strength indicator', 'theme-my-login' ); ?></div>
<p class="description indicator-hint"><?php _e( 'Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).' ); ?></p>
</td>
</tr>
<?php endif; ?>
</table>

<?php do_action( 'show_user_profile', $profileuser ); ?>

<p class="submit">
<input type="hidden" name="action" value="profile" />
<input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $current_user->ID ); ?>" />
<input type="submit" class="button-primary" value="<?php esc_attr_e( 'Update Profile' ); ?>" name="submit" />
</p>
</form>
</div>


if anyone has any bright ideas of how to conditionally show a editable user profile with custom fields dependant on their role it would be great.