BuddyBoss Home – Web Support Forums Themes Boss. theme How to Add Points Shortcode to Header via PHP

Viewing 13 posts - 1 through 13 (of 13 total)
  • Question

    #43293
    @producia

    Hi,

    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

    #43327

    Deepak BuddyBoss
    Participant
    @deepak

    @producia After line 80 in header.php paste this:
    <? echo 'My Points: '.do_shortcode( '[mycred_my_balance]' ); ?>

    #43328
    @producia

    Hi 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.

    #43376

    Deepak BuddyBoss
    Participant
    @deepak

    @producia I think we have different header.php files, place it AFTER this text in the header.php file:
    <div class="middle-col">

    #43378
    @producia

    Hi 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">
    
    #43464

    Deepak BuddyBoss
    Participant
    @deepak

    @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.

    #43467
    @producia

    Ahh 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!

    #43562

    Deepak BuddyBoss
    Participant
    @deepak

    Great, glad you were able to get this sorted out 🙂

    #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?

    #63506
    @vapvarun

    Hi @wrkazigmail
    following should work fine

    mycred_my_balance

    
    <?php echo 'My Points: '.do_shortcode( '[mycred_my_balance]' ); ?>
    

    Regards
    Varun Dubey

    #63507
    @vapvarun

    Ideally 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 Dubey

    #63516
    @wrkazigmail

    thanks 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?

    #63539
    @vapvarun

    Hi @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

Viewing 13 posts - 1 through 13 (of 13 total)
  • The question ‘How to Add Points Shortcode to Header via PHP’ is closed to new replies.