-
Author
-
October 5, 2017 at 10:36 #175737
halmatro
ParticipantThe issue can be seen only from a registered user view.
What I am trying to achieve is the following:
I have installed a plugin called ” Buddy Profile Data ” from here https://www.philopress.com/products/buddyprofiledata/ – Bought the plugin and installed.
After installation here is how it looks, see users photo.
I want to have the following text fit in the Member box :
Gender: MaleStudent or Teacher: StudentCountry: AustraliaCourses/subject : YZCourses/subject – Level: High SchoolDetails: 1984Here is the plugin PHP Code for shop-profile-data.php:
<?php
function bp_show_profile_data_init() {
if ( is_admin() ) {
if ( !is_super_admin() )
return;if ( isset( $_GET[‘page’] ) ) {
if ( $_GET[‘page’] == ‘bp-show-profile-data’) {
add_action( ‘admin_enqueue_scripts’, ‘bp_show_profile_data_admin_scripts’ );
add_action( ‘admin_enqueue_scripts’, ‘bp_show_profile_data_admin_styles’ );}
}
$bp_profile_data_instance = new BP_Show_Profile_Data_Admin();}
else {
// Enqueue frontend styles
if ( bp_is_members_component() || bp_is_group_members() )
add_action( ‘wp_enqueue_scripts’, ‘bp_show_profile_data_styles’ );}
}
add_action( ‘bp_init’, ‘bp_show_profile_data_init’ );function bp_show_profile_data_admin_scripts() {
wp_enqueue_script( ‘jquery-ui-sortable’ );
wp_enqueue_script( ‘buddyprofile-admin-script’, plugins_url( ‘admin/js/buddy-profile-admin-scripts.js’ , __FILE__ ), array(‘jquery-ui-sortable’) );
}function bp_show_profile_data_admin_styles() {
wp_enqueue_style( ‘buddyprofile-admin-styles’, plugins_url( ‘admin/css/buddy-profile-admin-styles.css’ , __FILE__ ), array() );
}// Register stylesheet for BP members lists
function bp_show_profile_data_styles() {
$file_exists = file_exists( get_stylesheet_directory() . ‘/buddy-profile-data.css’);if( $file_exists ) :
wp_enqueue_style( ‘buddyprofiledata-styles’, get_stylesheet_directory_uri() . ‘/buddy-profile-data.css’, array() );
else:
wp_enqueue_style( ‘buddyprofiledata-styles’, plugins_url(‘/css/buddy-profile-data.css’,__FILE__) , array() );
endif;
}/*
* Admin Page class
*
*/class BP_Show_Profile_Data_Admin {
private $pages_message = ”; // success / error message for page selection
private $fields_message = ”; // success / error message for fields selection
private $allowed_fields = array(); // all the profile fields to show – set in function gather_profile_fields()
private $allowed_pages = array(‘members’, ‘groups’ ); // all the potential pages on which to display fieldspublic function __construct() {
$this->gather_profile_fields();
$this->pages_update();
$this->fields_update();add_action(‘admin_menu’, array($this, ‘bp_profile_data_admin_menu’), 99);
add_action( ‘network_admin_menu’, array($this, ‘bp_profile_data_network_admin_menu’), 99);}
function bp_profile_data_network_admin_menu() {
add_submenu_page(‘settings.php’, ‘BuddyProfileData’, ‘BuddyProfileData’, ‘manage_options’, ‘bp-show-profile-data’, array( $this, ‘bp_profile_data_admin_screen’ ) );
}function bp_profile_data_admin_menu() {
add_options_page( __( ‘BuddyProfileData’, ‘bp-show-profile-data’), __( ‘BuddyProfileData’, ‘bp-show-profile-data’ ), ‘manage_options’, ‘bp-show-profile-data’, array( $this, ‘bp_profile_data_admin_screen’ ) );
}
function bp_profile_data_admin_screen() {
?>
<div class=”wrap”><div id=”icon-tools” class=”icon32″><br /></div>
<h2><?php _e( ‘BuddyProfileData’, ‘bp-show-profile-data’ )?></h2>
<br /><?php if ( bp_is_active( ‘xprofile’ ) ) { ?>
<?php _e( ‘Profile data is shown in various places in BuddyPress.’, ‘bp-show-profile-data’ )?>
<br />
<?php _e( ‘This page controls the additional display of the selected profile fields on the selected pages.’, ‘bp-show-profile-data’ )?><?php
$this->bp_profile_data_forms();}
else
echo ‘<br>Please enable the BuddyPress Extended Profile component.’;
?>
</div>
<?php
}private function bp_profile_data_forms() {
?>
<table border=”0″ cellspacing=”10″ cellpadding=”10″>
<tr>
<td style=”vertical-align:top; border: 1px solid #ccc;” ><h3><?php _e(‘Which pages should show profile data?’, ‘bp-show-profile-data’); ?></h3>
<?php echo $this->pages_message; ?>
<form action=”” name=”profile-data-pages-form” id=”profile-data-pages-form” method=”post” class=”standard-form”>
<?php wp_nonce_field(‘profile-data-pages-action’, ‘profile-data-pages-field’); ?>
<ul id=”pp-profile-data-pages-list”>
<?php
$current_pages = explode(“,”, get_option( ‘pp_profile_data_pages’ ));foreach ($this->allowed_pages as $allowed_page => $value) {
if( in_array( $value, $current_pages ) ) $checked = ‘ checked=”checked”‘;
else $checked = ”;if( ‘groups’ == $value ) $shown_value = ‘Group Members’;
else $shown_value = ucfirst($value);
?><li><label for=”bp-allowed-pages-<?php echo $value; ?>”><input id=”pp-allowed-pages-<?php echo $value; ?>” type=”checkbox” name=”pages[]” value=”<?php echo $value; ?>” <?php echo $checked; ?> /> <?php echo $shown_value; ?></label></li>
<?php } ?>
</ul><input type=”hidden” name=”profile-data-pages-access” value=”1″/>
<input type=”submit” name=”submit” class=”button button-primary” value=”<?php _e(‘Save Changes’, ‘bp-show-profile-data’); ?>”/>
</form></td>
<td style=”vertical-align:top; border: 1px solid #ccc;” >
<h3><?php _e(‘Which profile fields should be shown?’, ‘bp-show-profile-data’); ?></h3>
<?php echo $this->fields_message; ?>
<?php _e(‘Drag checked boxes to set display order.’, ‘bp-show-profile-data’); ?>
<br />
<?php _e(‘Visibility settings will be honored.’, ‘bp-show-profile-data’); ?><form action=”” name=”profile-data-fields-form” id=”profile-data-fields-form” method=”post” class=”standard-form”>
<?php wp_nonce_field(‘profile-data-fields-action’, ‘profile-data-fields-field’); ?>
<div id=”pp-profile-data-fields”>
<ul id=”pp-profile-data-fields-list” class=”ui-sortable”><?php
$current_fields = get_option( ‘pp_profile_data_fields’ );if( $current_fields != false ) {
foreach ($current_fields as $key => $value) {
if( !empty( $value ) ) {
$field_name = $this->allowed_fields[$value];
unset( $this->allowed_fields[$value] );?>
<li><label for=”pp-allowed-fields-<?php echo $field_name; ?>”><input id=”pp-allowed-fields-<?php echo $field_name; ?>” type=”checkbox” name=”fields[]” value=”<?php echo $value; ?>” checked=”checked”‘/> <?php echo stripslashes(ucfirst($field_name)); ?></label></li><?php
}
}
} ?><?php foreach ($this->allowed_fields as $key => $value) { ?>
<li><label for=”pp-allowed-fields-<?php echo $value; ?>”><input id=”pp-allowed-fields-<?php echo $value; ?>” type=”checkbox” name=”fields[]” value=”<?php echo $key; ?>” /> <?php echo stripslashes( ucfirst($value) ); ?></label></li>
<?php } ?>
</ul>
</div><input type=”hidden” name=”profile-data-fields-access” value=”1″/>
<input type=”submit” name=”submit” class=”button button-primary” value=”<?php _e(‘Save Changes’, ‘bp-show-profile-data’); ?>”/>
</form>
</td>
</tr></table><?php
}// save any changes to pages options
private function pages_update() {if( isset( $_POST[‘profile-data-pages-access’] ) ) {
if( !wp_verify_nonce($_POST[‘profile-data-pages-field’],’profile-data-pages-action’) )
die(‘Security check’);if( !is_super_admin() )
return;$updated = 0;
if( isset( $_POST[‘pages’] ) ) {
foreach( $_POST[‘pages’] as $key => $value ){
if( in_array( $value, $this->allowed_pages ) ) {
$new_pages[] = $value;
}
}$new_pages = implode(“,”, $new_pages);
$updated = update_option( ‘pp_profile_data_pages’, $new_pages );} else {
delete_option( ‘pp_profile_data_pages’ );
$updated = 1;
}if( $updated )
$this->pages_message .=
“<div class=’updated below-h2′>” . __(‘Pages have been updated.’, ‘bp-show-profile-data’) . “</div>”;
else
$this->pages_message .=
“<div class=’updated below-h2′ style=’color: red’>” . __(‘No changes were detected re Pages.’, ‘bp-show-profile-data’) . “</div>”;}
}// save any changes to fields options
private function fields_update() {if ( isset( $_POST[‘profile-data-fields-access’] ) ) {
if ( !wp_verify_nonce($_POST[‘profile-data-fields-field’],’profile-data-fields-action’) )
die(‘Security check’);if ( !is_super_admin() )
return;$updated = 0;
if ( isset( $_POST[‘fields’] ) ) {
$new_fields = array();
foreach( $_POST[‘fields’] as $key => $value ){
if( array_key_exists($value, $this->allowed_fields ) ) {
$new_fields[] = $value;
}
}if( !empty( $new_fields ) )
$updated = update_option( ‘pp_profile_data_fields’, $new_fields );} else {
delete_option( ‘pp_profile_data_fields’ );
$updated = 1;
}if ( $updated )
$this->fields_message .=
“<div class=’updated below-h2′>” . __(‘Fields have been updated.’, ‘bp-show-profile-data’) . “</div>”;
else
$this->fields_message .=
“<div class=’updated below-h2′ style=’color: red’>” . __(‘No changes were detected re Fields.’, ‘bp-show-profile-data’) . “</div>”;
}
}// get all the profile field ids and names
private function gather_profile_fields() {$groups = BP_XProfile_Group::get( array( ‘fetch_fields’ => true ) ); // from bp-xprofile/bp-xprofile-admin.php
if ( !empty( $groups ) ) {
foreach ( $groups as $group ) {
if ( !empty( $group->fields ) ) {
foreach ( $group->fields as $field ) {
$this->allowed_fields[$field->id] = $field->name;
}
}
}
}
}} // end of class BP_Show_Profile_Data_Admin
/*
* Display the selected profile data on selected pages
*
*/function bp_show_profile_data_display() {
global $wpdb, $bp;if ( bp_is_current_component( $bp->groups->slug ) ) {
$user_id = bp_get_group_member_id();
echo ‘<div id=”pp-profile-data-groups”>’;
} else if ( bp_is_current_component( $bp->members->slug ) ) {
$user_id = bp_get_member_user_id();
echo ‘<div id=”pp-profile-data-members”>’;
} else
return;$current_fields = get_option( ‘pp_profile_data_fields’ );
$hidden_fields = bp_xprofile_get_hidden_fields_for_user( $user_id, $current_user_id = bp_loggedin_user_id() );
if( $current_fields != false ) {
foreach( $current_fields as $key => $value ) {if ( !in_array( $value, $hidden_fields ) ) {
//$field_data = $wpdb->get_row( “SELECT * FROM {$wpdb->prefix}bp_xprofile_fields WHERE id = $value” ); // does not work in multisite
$field_data = $wpdb->get_row( $wpdb->prepare( “SELECT * FROM {$bp->profile->table_name_fields} WHERE id = %d”, $value ) );$field_value = xprofile_get_field_data( $value, $user_id, $multi_format = ‘comma’ );
$field_value = xprofile_filter_format_field_value( $field_value, $field_type = $field_data->type );
$field_value = apply_filters( ‘pp-show-profile-data-val’, $field_value );
if( ” != $field_value )
echo ‘<div id=pp-profile-data-name>’ . stripslashes($field_data->name) . ‘:</div><div id=pp-profile-data-value>’ . $field_value . ‘</div><div style=”clear:both”></div>’;
}
}
}echo ‘</div>’;
}
add_action( ‘bp_group_members_list_item’, ‘bp_show_profile_data_display’ );
add_action( ‘bp_directory_members_item’, ‘bp_show_profile_data_display’ );
?>Here is the plugin PHP Code for loader.php:
<?php
/*
Plugin Name: BuddyProfileData
Description: Displays profile data into each entry on pages that you choose. You also choose which data to display. Find your options on Settings -> BuddyProfileData.
Version: 1.1
Author: PhiloPress
Author URI: http://philopress.com/
License: GPLv2
Copyright (C) 2013 shanebp, PhiloPress
*/if ( !defined( ‘ABSPATH’ ) ) exit;
function bp_show_profile_data_include() {
require( dirname( __FILE__ ) . ‘/bp-show-profile-data.php’ );
load_plugin_textdomain( ‘bp-show-profile-data’, false, dirname( plugin_basename( __FILE__ ) ) . ‘/languages/’ );
}
add_action( ‘bp_include’, ‘bp_show_profile_data_include’ );?>
Here is the plugin CSS Code:
/*
* This file provides default styling for profile field display in BP member lists
*
* Styling is based on twentytwelve theme & is kept as minimal you will need to
* customize to suit your chosen theme.
*
* You can overload this file by moving it as a copy to your theme directory or
* simply add your styles to your themes stylesheets
*
* @package BuddyProfileData
* @version buddyprofiledata 1.0
*/div#pp-profile-data-members {
margin-left: 250px;
margin-top: -50px;
position: absolute;
width: 200px;
font-size: 80%;
}div#pp-profile-data-groups {
margin-left: 250px;
margin-top: -125px;
position: absolute;
width: 200px;
font-size: 80%;
}div#pp-profile-data-name {
width: 50%;
float: left;
overflow: hidden;
font-size: 80%;
font-weight: bold;
}div#pp-profile-data-value {
width: 50%;
float: left;
overflow: hidden;
font-size: 80%;
}Could you please advise ?
If you want I can provide access to the website in order to fix this issue.
-
AuthorPosts
The forum ‘Bugs & Issues’ is closed to new topics and replies.