How to create profile fields from another plugin
-
Hi guys,
i’ve installed liveTV bundle ( http://wordpress.org/extend/plugins/livetv-bundle/ ), but this plugin show the profile fields only in the normal profile panel not in buddypress. so my question is, how can i change it to my buddypress profiles? The developer of this plugin, told me that i should ask a buddypress expert.Sorry about my bad english, but i really need your help.
Heres the code if you need it: (liveTV/page-admin/page-admin-livestreams.php)
Code://Now hook to create extra profil fields
add_action( ‘edit_user_profile’, ‘livetv_show_extra_profile_fields’ );
//When the current on the current profil has capabilties to edit -> display
add_action( ‘edit_user_profile_update’, ‘livetv_save_extra_profile_fields’ );
//When the current on the current profil has capabilties to edit -> updateadd_action( ‘show_user_profile’, ‘livetv_show_extra_profile_fields’ );
//When the current on the current profil has capabilties to show -> display
add_action( ‘personal_options_update’, ‘livetv_save_extra_profile_fields’ );
//When the current on the current profil is the current and edit -> updateif(!is_admin)
{
//Frontend plugins compatibility
add_action(‘profile_personal_options’, ‘livetv_show_extra_profile_fields’);
//When the current on the current profil is the current and show -> display
}//Now construct new profil fields access, based on option of the plugin (default wordpress roles or new roles)
function livetv_show_extra_profile_fields( $user )
{
$userID = $user->ID;$access = get_option(‘livetv_activate_creation_role’);
//If based on new roles
if($access == ‘on’)
{
$editable_roles = get_roles();foreach ($editable_roles as $key => $value)
{
$temp = preg_match("#^live_#", $key);if($temp == true)
{
if (current_user_can(”.$key.”))
{
$live_profil = ‘1’;
}
else
{
$live_profil = ‘0’;
}
}
}
}//If based on wordpress role
if($access == ‘off’)
{
$defautRole = get_option(‘livetv_defaut_role_wordpress’);if (current_user_can(”.$defautRole.”))
{
$live_profil = ‘1’;
}
else
{
$live_profil = ‘0’;
}
}//Administrator have already access to all profils
if (current_user_can(‘administrator’))
{
$live_profil = ‘1’;
}//Result to displaying profil fields
if($live_profil == ‘1’){if(is_admin()){$tableclass = ‘widefat options’;}else{$tableclass = ‘form-table’;} ?>
<table class="<?php echo $tableclass; ?>" style="width: 600px">
<h3>
<?php _e(‘Stream hinzufügen’); ?>
</h3><th colspan="2" class="dashboard-widget-title"><?php _e(‘Channel hinzufügen’, ‘livetv’); ?></th>
<?php
$types = explode(‘_’, get_option(‘livetv_types_order’));
foreach($types as $key => $type)
{ ?>
<tr valign="top">
<td scope="row"><label>
<?php _e(‘Dein Channel auf’, ‘livetv’); echo ‘ ‘. $type; ?>
</label></td>
<td class="livetv-admin-td"><input type="text" style="width:125px;" maxlength="55" name="live_<?php echo $type; ?>" id="live_<?php echo $type; ?>" class="regular-text" />
<span class="livetv_help" title="<?php _e(‘Füge einen Channelnamen oder eine Channel ID hinzu.’, ‘livetv’); ?><?php echo ‘ ‘ . $type. ‘.tv ‘; ?><?php _e(‘oder lasse es frei.’, ‘livetv’); ?>"></span><br /></td>
</tr>
<?php } ?>
</table>
<?php
foreach($types as $key => $type)
{
$countlive = get_user_meta($userID, ‘count_live_’.$type.”, true);
if($countlive) { ?>
<br />
<table class="widefat options" style="width: 600px"><th colspan="2" class="dashboard-widget-title"><?php _e(‘Deine aktiven Channel auf ‘, ‘livetv’); echo $type; ?>
<span class="mini-<?php echo $type; ?>"></span></th>
<tr valign="top">
<td scope="row"><label><?php _e(‘Entferne einen deiner Channel’, ‘livetv’) ?></label></td>
<td class="livetv-admin-td"><select name="delete_one_<?php echo ”.$type.” ?>" id="delete_one_<?php echo ”.$type.” ?>">
<option value=""><?php echo ” ?></option>
<?php
global $wpdb;
$thumbs = $wpdb->get_results( "SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE meta_key LIKE ‘live_".$userID."_".$type."_%’" );
foreach($thumbs as $keythumb => $valuethumb)
{
?>
<option value="<?php echo ”.$valuethumb->meta_key.”; ?>"><?php echo $valuethumb->meta_value; ?></option>
<?php } ?>
</select>
<span class="livetv_help" title="<?php _e(‘Wähle löschen und klicke auf Registrieren um den Channel zu löschen’, ‘livetv’); ?>"></span><br /></td>
</tr>
<?php foreach($thumbs as $keythumb => $valuethumb)
{
?>
<tr valign="top">
<td scope="row"><label><?php echo ‘ID ‘ ?>
<input type="text" style="width:50px;" maxlength="55" disabled="disabled" value="<?php echo $keythumb + 1; ?>" />
</label></td>
<td class="livetv-admin-td"><input type="text" style="width:125px;" maxlength="55" disabled="disabled" name="<?php echo $valuethumb->meta_value; ?>" value="<?php echo $valuethumb->meta_value; ?>" id="<?php echo ”.$valuethumb->meta_key.” ?>" />
<span class="livetv_help" title="<?php _e(‘Dieser Channel wird auf unserer Stream Seite angezeigt.’, ‘livetv’); ?>"></span></td>
</tr>
<?php } ?>
</table>
<?php }}}}//Profil field update function
function livetv_save_extra_profile_fields( $user_id )
{
if ( current_user_can( ‘edit_user’, $user_id ) )
{if(isset($_POST[‘delete_one_own3d’]) && !empty($_POST[‘delete_one_own3d’]))
{
$temp = stripslashes($_POST[‘delete_one_own3d’]);if($temp)
{
delete_user_meta( $user_id, ”.$temp.”);
}
}if(isset($_POST[‘delete_one_justin’]) && !empty($_POST[‘delete_one_justin’]))
{
$temp = stripslashes($_POST[‘delete_one_justin’]);if($temp)
{
delete_user_meta( $user_id, ”.$temp.”);
}
}if(isset($_POST[‘delete_one_twitch’]) && !empty($_POST[‘delete_one_twitch’]))
{
$temp = stripslashes($_POST[‘delete_one_twitch’]);if($temp)
{
delete_user_meta( $user_id, ”.$temp.”);
}
}if(isset($_POST[‘live_own3d’]) && $_POST[‘live_own3d’] != ”)
{$countlive = get_user_meta($user_id, ‘count_live_own3d’, true);
if(!$countlive){
$countlive = ‘0’;
}$count = $countlive + ‘1’;
update_user_meta( $user_id, ‘count_live_own3d’, ”.$count.”);
update_user_meta( $user_id, ‘live_’.$user_id.’_own3d_’.$count.”, $_POST[‘live_own3d’] );
}if(isset($_POST[‘live_justin’]) && $_POST[‘live_justin’] != ”)
{$countlive = get_user_meta($user_id, ‘count_live_justin’, true);
if(!$countlive){
$countlive = ‘0’;
}$count = $countlive + ‘1’;
update_user_meta( $user_id, ‘count_live_justin’, ”.$count.”);
update_user_meta( $user_id, ‘live_’.$user_id.’_justin_’.$count.”, $_POST[‘live_justin’] );
}if(isset($_POST[‘live_twitch’]) && $_POST[‘live_twitch’] != ”)
{$countlive = get_user_meta($user_id, ‘count_live_twitch’, true);
if(!$countlive){
$countlive = ‘0’;
}$count = $countlive + ‘1’;
update_user_meta( $user_id, ‘count_live_twitch’, ”.$count.”);
update_user_meta( $user_id, ‘live_’.$user_id.’_twitch_’.$count.”, $_POST[‘live_twitch’] );
}
}
}
?>Greetz
- The topic ‘How to create profile fields from another plugin’ is closed to new replies.