BuddyBoss Home – Web › Support Forums › Themes › Boss. theme › How to Add Points Shortcode to Header via PHP
Tagged: custom code, header, points
- This topic has 12 replies, 4 contibutors, and was last updated 8 years, 8 months ago by Anonymous.
-
Question
July 25, 2015 at 9:30 pm #43293@produciaHi,
I’m using the MyCRED points plugin and I would like to display the user’s points in the header using the following code:
echo do_shortcode( ‘[mycred_my_balance]’ );
I added this PHP code to the header.php file and it didn’t display my points. Is this possible to do with this theme?
Please see attached screenshot on see an example of what I’m trying to do.
Thanks
Answers
July 26, 2015 at 2:12 pm #43327@alyssa-buddyboss
AlyssaParticipant@producia After line 80 in header.php paste this:
<? echo 'My Points: '.do_shortcode( '[mycred_my_balance]' ); ?>
July 26, 2015 at 2:23 pm #43328@produciaHi TJ,
I’ve added the code but it’s still not displaying. I’ve attached a screen shot of my Notepad++ screen. I am using the child theme and copied Header.php to that folder. I also tried the code in the main theme files too and no changes unfortunately.
July 27, 2015 at 12:23 pm #43376@alyssa-buddyboss
AlyssaParticipant@producia I think we have different header.php files, place it AFTER this text in the header.php file:
<div class="middle-col">
July 27, 2015 at 12:37 pm #43378@produciaHi TJ,
I searched for that code and couldn’t find it in header.php…Below is the file for you to see…
?php /** * The Header for your theme. * * Displays all of the <head> section and everything up until <div id="main"> * * @package WordPress * @subpackage BuddyBoss * @since BuddyBoss 3.0 */ ?><!DOCTYPE html> <!--[if IE 8]> <html class="ie ie8" <?php language_attributes(); ?>> <![endif]--> <!--[if IE > 8]> <html class="ie" <?php language_attributes(); ?>> <![endif]--> <!--[if ! IE ]><!--> <html <?php language_attributes(); ?>> <!--<![endif]--> <head> <meta charset="<?php bloginfo( 'charset' ); ?>" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="msapplication-tap-highlight" content="no"/> <title><?php wp_title( '|', true, 'right' ); ?></title> <link rel="profile" href="http://gmpg.org/xfn/11" /> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" /> <link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/images/favicon.ico" type="image/x-icon"> <!-- BuddyPress and bbPress Stylesheets are called in wp_head, if plugins are activated --> <?php wp_head(); ?> </head> <body <?php if ( current_user_can('manage_options') ) : ?>id="role-admin"<?php endif; ?> <?php body_class(); ?>> <?php do_action( 'buddyboss_before_header' ); ?> <header id="masthead" class="site-header" role="banner"> <div class="header-inner"> <!-- Look for uploaded logo --> <?php if ( get_theme_mod( 'buddyboss_logo' ) ) : ?> <div id="logo"> <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><img src="<?php echo esc_url( get_theme_mod( 'buddyboss_logo' ) ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"></a> </div> <!-- If no logo, display site title and description --> <?php else: ?> <div class="site-name"> <h1 class="site-title"> <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"> <?php bloginfo( 'name' ); ?> </a> </h1> <p class="site-description"><?php bloginfo( 'description' ); ?></p> </div> <?php endif; ?> <!-- Register/Login links for logged out users --> <?php if ( !is_user_logged_in() && buddyboss_is_bp_active() && !bp_hide_loggedout_adminbar( false ) ) : ?> <div class="header-account"> <?php if ( buddyboss_is_bp_active() && bp_get_signup_allowed() ) : ?> <a href="<?php echo bp_get_signup_page(); ?>"><?php _e( 'Register', 'buddyboss' ); ?></a> <?php endif; ?> <a href="<?php echo wp_login_url(); ?>" class="button"><?php _e( 'Login', 'buddyboss' ); ?></a> </div> <?php endif; ?> </div> <nav id="site-navigation" class="main-navigation" role="navigation"> <div class="nav-inner"> <?php echo 'My Points: '.do_shortcode( '[mycred_my_balance]' ); ?> <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'buddyboss' ); ?>"><?php _e( 'Skip to content', 'buddyboss' ); ?></a> <?php wp_nav_menu( array( 'theme_location' => 'primary-menu', 'menu_class' => 'nav-menu clearfix' ) ); ?> </div> </nav><!-- #site-navigation --> </header><!-- #masthead --> <?php do_action( 'buddyboss_after_header' ); ?> <div id="mobile-header"> <!-- Toolbar for Mobile --> <div class="mobile-header-inner"> <!-- Left button --> <?php if ( is_user_logged_in() || ( !is_user_logged_in() && buddyboss_is_bp_active() && !bp_hide_loggedout_adminbar( false ) ) ) : ?> <div id="user-nav" class="left-btn"></div> <?php endif; ?> <!-- Right button --> <div id="main-nav" class="right-btn"></div> </div> <h1><a class="mobile-site-title" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> </div><!-- #mobile-header --> <div id="main-wrap"> <!-- Wrap for Mobile content --> <div id="inner-wrap"> <!-- Inner Wrap for Mobile content --> <?php do_action( 'buddyboss_inside_wrapper' ); ?> <div id="page" class="hfeed site"> <div id="main" class="wrapper">
July 28, 2015 at 1:41 pm #43464@alyssa-buddyboss
AlyssaParticipant@producia I’m afraid the picture you posted is for the Boss theme but your header.php text is for the BuddyBoss theme. I think you need to figure out which one you are actually editing and get back to me.
July 28, 2015 at 1:46 pm #43467@produciaAhh damn…Sorry about that. Got both themes installed and didn’t notice that. I just added the php code to the header and it is now working.
Thanks for your help!
July 29, 2015 at 4:03 pm #43562@alyssa-buddyboss
AlyssaParticipantGreat, glad you were able to get this sorted out 🙂
March 12, 2016 at 1:12 am #62639@wrkazigmail<? echo ‘My Points: ‘.do_shortcode( ‘[mycred_my_balance]’ ); ?> doesnt work with the latest boss version. where excatly it has to be placed in the new version?
March 17, 2016 at 1:13 am #63506@
AnonymousHi @wrkazigmail
following should work fine<?php echo 'My Points: '.do_shortcode( '[mycred_my_balance]' ); ?>
Regards
Varun DubeyMarch 17, 2016 at 1:16 am #63507@
AnonymousIdeally it need to be added inside
boss/buddypress/members/single/member-header.php after replacing badgeos point codes.
Line 124-125.
Rest depended upon your requirement where you need to display at your site.
Boss have dedicated support of BadgeOs , functions and css are included at their desired location.
Regards
Varun DubeyMarch 17, 2016 at 1:53 am #63516@wrkazigmailthanks varun..will check this out and update you…any reasons you given badgeos support and not mycred support?
i remember my cred had a specific plugin for buddyboss theme which used to allow users to get points for posting on wall and uploading pics…
why did you stop support for mycred and why dedicated suppport for badgeos?
March 17, 2016 at 4:33 am #63539@
AnonymousHi @wrkazigmail We have not stopped support for MyCred , badgeos specific dedicated css ( like alignment of badges on header cover image ) is included in last update which was earlier part of Social Learner package.
If you need to display some functionality at specific location , it obviously need codes edits that’s why you will need add shortcodes inside the child theme files
Regards
- The question ‘How to Add Points Shortcode to Header via PHP’ is closed to new replies.