Created
January 22, 2019 02:56
-
-
Save champsupertramp/29ad84d3db18791a51a571d162f42df7 to your computer and use it in GitHub Desktop.
Ultimate Member - Customise profile header
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action("init","um_custom_init"); | |
function um_custom_init(){ | |
remove_action( 'um_profile_header', 'um_profile_header', 9 ); | |
add_action( 'um_profile_header', 'um_custom_profile_header', 9 ); | |
} | |
/** | |
* Profile header | |
* | |
* @param $args | |
*/ | |
function um_custom_profile_header( $args ) { | |
$classes = null; | |
if (!$args['cover_enabled']) { | |
$classes .= ' no-cover'; | |
} | |
$default_size = str_replace( 'px', '', $args['photosize'] ); | |
$overlay = '<span class="um-profile-photo-overlay"> | |
<span class="um-profile-photo-overlay-s"> | |
<ins> | |
<i class="um-faicon-camera"></i> | |
</ins> | |
</span> | |
</span>'; | |
?> | |
<div class="um-header<?php echo $classes; ?>"> | |
<?php | |
/** | |
* UM hook | |
* | |
* @type action | |
* @title um_pre_header_editprofile | |
* @description Insert some content before edit profile header | |
* @input_vars | |
* [{"var":"$args","type":"array","desc":"Form Arguments"}] | |
* @change_log | |
* ["Since: 2.0"] | |
* @usage add_action( 'um_pre_header_editprofile', 'function_name', 10, 1 ); | |
* @example | |
* <?php | |
* add_action( 'um_pre_header_editprofile', 'my_pre_header_editprofile', 10, 1 ); | |
* function my_pre_header_editprofile( $args ) { | |
* // your code here | |
* } | |
* ?> | |
*/ | |
do_action( 'um_pre_header_editprofile', $args ); ?> | |
<div class="um-profile-photo" data-user_id="<?php echo um_profile_id(); ?>"> | |
<a href="javascript:;" class="um-profile-photo-img" | |
title="<?php echo um_user( 'display_name' ); ?>"><?php echo $overlay . get_avatar( um_user( 'ID' ), $default_size ); ?></a> | |
<?php | |
if (!isset( UM()->user()->cannot_edit )) { | |
UM()->fields()->add_hidden_field( 'profile_photo' ); | |
if (!um_profile( 'profile_photo' )) { // has profile photo | |
$items = array( | |
'<a href="#" class="um-manual-trigger" data-parent=".um-profile-photo" data-child=".um-btn-auto-width">' . __( 'Upload photo', 'ultimate-member' ) . '</a>', | |
'<a href="#" class="um-dropdown-hide">' . __( 'Cancel', 'ultimate-member' ) . '</a>', | |
); | |
/** | |
* UM hook | |
* | |
* @type filter | |
* @title um_user_photo_menu_view | |
* @description Change user photo on menu view | |
* @input_vars | |
* [{"var":"$items","type":"array","desc":"User Photos"}] | |
* @change_log | |
* ["Since: 2.0"] | |
* @usage | |
* <?php add_filter( 'um_user_photo_menu_view', 'function_name', 10, 1 ); ?> | |
* @example | |
* <?php | |
* add_filter( 'um_user_photo_menu_view', 'my_user_photo_menu_view', 10, 1 ); | |
* function my_user_photo_menu_view( $items ) { | |
* // your code here | |
* return $items; | |
* } | |
* ?> | |
*/ | |
$items = apply_filters( 'um_user_photo_menu_view', $items ); | |
echo UM()->profile()->new_ui( 'bc', 'div.um-profile-photo', 'click', $items ); | |
} else if (UM()->fields()->editing == true) { | |
$items = array( | |
'<a href="#" class="um-manual-trigger" data-parent=".um-profile-photo" data-child=".um-btn-auto-width">' . __( 'Change photo', 'ultimate-member' ) . '</a>', | |
'<a href="#" class="um-reset-profile-photo" data-user_id="' . um_profile_id() . '" data-default_src="' . um_get_default_avatar_uri() . '">' . __( 'Remove photo', 'ultimate-member' ) . '</a>', | |
'<a href="#" class="um-dropdown-hide">' . __( 'Cancel', 'ultimate-member' ) . '</a>', | |
); | |
/** | |
* UM hook | |
* | |
* @type filter | |
* @title um_user_photo_menu_edit | |
* @description Change user photo on menu edit | |
* @input_vars | |
* [{"var":"$items","type":"array","desc":"User Photos"}] | |
* @change_log | |
* ["Since: 2.0"] | |
* @usage | |
* <?php add_filter( 'um_user_photo_menu_edit', 'function_name', 10, 1 ); ?> | |
* @example | |
* <?php | |
* add_filter( 'um_user_photo_menu_edit', 'my_user_photo_menu_edit', 10, 1 ); | |
* function my_user_photo_menu_edit( $items ) { | |
* // your code here | |
* return $items; | |
* } | |
* ?> | |
*/ | |
$items = apply_filters( 'um_user_photo_menu_edit', $items ); | |
echo UM()->profile()->new_ui( 'bc', 'div.um-profile-photo', 'click', $items ); | |
} | |
} | |
?> | |
</div> | |
<div class="um-profile-meta"> | |
<?php | |
/** | |
* UM hook | |
* | |
* @type action | |
* @title um_before_profile_main_meta | |
* @description Insert before profile main meta block | |
* @input_vars | |
* [{"var":"$args","type":"array","desc":"Form Arguments"}] | |
* @change_log | |
* ["Since: 2.0.1"] | |
* @usage add_action( 'um_before_profile_main_meta', 'function_name', 10, 1 ); | |
* @example | |
* <?php | |
* add_action( 'um_before_profile_main_meta', 'my_before_profile_main_meta', 10, 1 ); | |
* function my_before_profile_main_meta( $args ) { | |
* // your code here | |
* } | |
* ?> | |
*/ | |
do_action( 'um_before_profile_main_meta', $args ); ?> | |
<div class="um-main-meta"> | |
<?php if ( $args['show_name'] ) { ?> | |
<div class="um-name"> | |
<a href="<?php echo um_user_profile_url(); ?>" | |
title="<?php echo um_user( 'display_name' ); ?>"><?php echo um_user( 'display_name', 'html' ); ?></a> | |
<?php | |
/** | |
* UM hook | |
* | |
* @type action | |
* @title um_after_profile_name_inline | |
* @description Insert after profile name some content | |
* @input_vars | |
* [{"var":"$args","type":"array","desc":"Form Arguments"}] | |
* @change_log | |
* ["Since: 2.0"] | |
* @usage add_action( 'um_after_profile_name_inline', 'function_name', 10, 1 ); | |
* @example | |
* <?php | |
* add_action( 'um_after_profile_name_inline', 'my_after_profile_name_inline', 10, 1 ); | |
* function my_after_profile_name_inline( $args ) { | |
* // your code here | |
* } | |
* ?> | |
*/ | |
do_action( 'um_after_profile_name_inline', $args ); ?> | |
</div> | |
<?php } ?> | |
<div class="um-clear"></div> | |
<?php | |
/** | |
* UM hook | |
* | |
* @type action | |
* @title um_after_profile_header_name_args | |
* @description Insert after profile header name some content | |
* @input_vars | |
* [{"var":"$args","type":"array","desc":"Form Arguments"}] | |
* @change_log | |
* ["Since: 2.0"] | |
* @usage add_action( 'um_after_profile_header_name_args', 'function_name', 10, 1 ); | |
* @example | |
* <?php | |
* add_action( 'um_after_profile_header_name_args', 'my_after_profile_header_name_args', 10, 1 ); | |
* function my_after_profile_header_name_args( $args ) { | |
* // your code here | |
* } | |
* ?> | |
*/ | |
do_action( 'um_after_profile_header_name_args', $args ); | |
/** | |
* UM hook | |
* | |
* @type action | |
* @title um_after_profile_name_inline | |
* @description Insert after profile name some content | |
* @change_log | |
* ["Since: 2.0"] | |
* @usage add_action( 'um_after_profile_name_inline', 'function_name', 10 ); | |
* @example | |
* <?php | |
* add_action( 'um_after_profile_name_inline', 'my_after_profile_name_inline', 10 ); | |
* function my_after_profile_name_inline() { | |
* // your code here | |
* } | |
* ?> | |
*/ | |
do_action( 'um_after_profile_header_name' ); ?> | |
</div> | |
<?php if (isset( $args['metafields'] ) && !empty( $args['metafields'] )) { ?> | |
<div class="um-meta"> | |
<?php echo UM()->profile()->show_meta( $args['metafields'] ); ?> | |
</div> | |
<?php } ?> | |
<?php if (UM()->fields()->viewing == true && um_user( 'description' ) && $args['show_bio']) { ?> | |
<div class="um-meta-text"> | |
<?php | |
$description = get_user_meta( um_user( 'ID' ), 'description', true ); | |
if ( UM()->options()->get( 'profile_show_html_bio' ) ) : ?> | |
<?php echo make_clickable( wpautop( wp_kses_post( $description ) ) ); ?> | |
<?php else : ?> | |
<?php echo esc_html( $description ); ?> | |
<?php endif; ?> | |
</div> | |
<?php } else if (UM()->fields()->editing == true && $args['show_bio']) { ?> | |
<div class="um-meta-text"> | |
<textarea id="um-meta-bio" | |
data-character-limit="<?php echo UM()->options()->get( 'profile_bio_maxchars' ); ?>" | |
placeholder="<?php _e( 'Tell us a bit about yourself...', 'ultimate-member' ); ?>" | |
name="<?php echo 'description-' . $args['form_id']; ?>" | |
id="<?php echo 'description-' . $args['form_id']; ?>"><?php echo UM()->fields()->field_value( 'description' ) ?></textarea> | |
<span class="um-meta-bio-character um-right"><span | |
class="um-bio-limit"><?php echo UM()->options()->get( 'profile_bio_maxchars' ); ?></span></span> | |
<?php | |
if (UM()->fields()->is_error( 'description' )) { | |
echo UM()->fields()->field_error( UM()->fields()->show_error( 'description' ), true ); | |
} | |
?> | |
</div> | |
<?php } ?> | |
<div class="um-profile-status <?php echo um_user( 'account_status' ); ?>"> | |
<span><?php printf( __( 'This user account status is %s', 'ultimate-member' ), um_user( 'account_status_name' ) ); ?></span> | |
</div> | |
<?php | |
/** | |
* UM hook | |
* | |
* @type action | |
* @title um_after_header_meta | |
* @description Insert after header meta some content | |
* @input_vars | |
* [{"var":"$user_id","type":"int","desc":"User ID"}, | |
* {"var":"$args","type":"array","desc":"Form Arguments"}] | |
* @change_log | |
* ["Since: 2.0"] | |
* @usage add_action( 'um_after_header_meta', 'function_name', 10, 2 ); | |
* @example | |
* <?php | |
* add_action( 'um_after_header_meta', 'my_after_header_meta', 10, 2 ); | |
* function my_after_header_meta( $user_id, $args ) { | |
* // your code here | |
* } | |
* ?> | |
*/ | |
do_action( 'um_after_header_meta', um_user( 'ID' ), $args ); ?> | |
</div> | |
<div class="um-clear"></div> | |
<?php if ( UM()->fields()->is_error( 'profile_photo' ) ) { | |
echo UM()->fields()->field_error( UM()->fields()->show_error( 'profile_photo' ), 'force_show' ); | |
} | |
/** | |
* UM hook | |
* | |
* @type action | |
* @title um_after_header_info | |
* @description Insert after header info some content | |
* @input_vars | |
* [{"var":"$user_id","type":"int","desc":"User ID"}, | |
* {"var":"$args","type":"array","desc":"Form Arguments"}] | |
* @change_log | |
* ["Since: 2.0"] | |
* @usage add_action( 'um_after_header_info', 'function_name', 10, 2 ); | |
* @example | |
* <?php | |
* add_action( 'um_after_header_info', 'my_after_header_info', 10, 2 ); | |
* function my_after_header_info( $user_id, $args ) { | |
* // your code here | |
* } | |
* ?> | |
*/ | |
do_action( 'um_after_header_info', um_user( 'ID' ), $args ); ?> | |
</div> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment