I want to show on the profile page of a user Only the fields that correspond to this role. Although there are many similar plugins for visibility of fields and roles, but not for this particular case – at least I think that’s correct not. Is there something?
Result should be that on my side a paying member you can view more information than free users.
Would großrtig if someone could help me this!
VG, Matthias
For this kind of functionality in the absence of buddypress I use Justin Tadlock’s Members plugin https://wordpress.org/plugins/members/ … His members plugin is the bare minimum essentials and no-fluff. Everything he writes is top-notch. There might be other options that are less flexible yet more simple for someone who doesn’t understand WordPress coding concepts well enough.
Für diese Art von Funktionalität in der Abwesenheit von Buddypress verwende ich Mitglieder Justin Tadlock die Plugin https://wordpress.org/plugins/members/ … Seine Mitglieder Plugin ist das absolute Minimum Wesentliche und nicht-Flaum. Alles, was er schreibt, ist erstklassig. Möglicherweise gibt es andere Optionen, die weniger flexibel noch einfacher für jemanden, der WordPress-Codierung Konzepte gut genug, nicht versteht, sind sein.
Hi Santeven, thanx for the quick answer!
My issue was meant the other way: all my members do have profile pages and I’d like to show more of a member’s info on his profile page if he has paid a medium or premium membership. The membership plugin does provide the membership handling with roles and payment but – as far as I saw – not the differenced appearence of the profile page according to the member’s role, not the viewer’s role. Or am I wrong? do you have other ideas? Best wishes, Matthias
You are welcome, Seems that is exactly what I do with the following code, adapted from Mr Tadlock’s:
<?php
/**
* Plugin Name: Tadlock User Meta for Cardiogolf
* Description: show the additional meta fields on user profile and allow editing on that page by admin
* Version: 1.0
* Author: Martin
*/
// show the fields
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<h3>Extra profile information</h3>
<table class="form-table">
<tr>
<th><label for="amount_last_pmt">Amount Last Payment</label></th>
<td>
<input type="text" name="amount_last_pmt" id="amount_last_pmt" value="<?php echo esc_attr( get_the_author_meta( 'amount_last_pmt', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">The amount of the last payment. (Should be read-only here for the user.)</span>
</td>
</tr>
<tr>
<th><label for="date_last_pmt">Date Last Payment via time(now)</label></th>
<td>
<input type="text" name="date_last_pmt" id="date_last_pmt" value="<?php echo esc_attr( get_the_author_meta( 'date_last_pmt', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">The date of the last payment via time(); . (Should be read-only here for the user.)</span>
</td>
</tr>
<tr>
<th><label for="entry_pmt_date">Date Last Payment via $entry</label></th>
<td>
<input type="text" name="entry_pmt_date" id="entry_pmt_date" value="<?php echo esc_attr( get_the_author_meta( 'entry_pmt_date', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">The entry's payment date. (Should be read-only here for the user.)</span>
</td>
</tr>
</table>
<?php }
// save the updated fields
add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
function my_save_extra_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
// Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID.
update_usermeta( $user_id, 'amount_last_pmt', $_POST['amount_last_pmt'] );
update_usermeta( $user_id, 'date_last_pmt', $_POST['date_last_pmt'] );
update_usermeta( $user_id, 'entry_pmt_date', $_POST['entry_pmt_date'] );
}
?>
Hi Martin, sorry, had some holidays 🙂
Where do I have to copy this code into? At the first glance it does not seem to only show my meta fields according to my role on the profile page, does it?