Cousepress 2 Instructors meta value

On Coursepress 1 I used this function in my theme to get some meta value:
<?php
foreach ( $instructors as $instructor ) {
?>

<h3><?php echo $instructor->display_name; ?></h3>

It gave me freedom to do some changes in how display info, like this:

<div>
<img src="<?php echo $avatar_url; ?>" />
<?php $currentlang = get_bloginfo('language');
if($currentlang=="pt-BR"):?>
<p>
<?php echo get_the_author_meta( 'cv_prof_br', $instructor->ID, 50 ); ?>
</p>

But it wont work on the new Coursepress2. How can I get these values now?

  • Rupok

    Hi Vivian,

    Thanks for asking. I'm pinging our devs regarding this as they can give us the best idea or workaround in this situation. I believe, they will come up with their valuable feedback soon. I'll update you as soon as I get something from them.

    Please keep in mind, our developers work round the clock and they have to deal with lots of critical issues and other things. So it may take a little while for them to check this and provide a feedback.

    Have a nice day. Cheers!
    Rupok

  • Vivian

    Is not that the problem. Im using a single-course.php template in my theme to display the course as I want.

    This:
    <?php
    foreach ( $instructors as $instructor ) {
    ?>
    <h3><?php echo $instructor->display_name; ?></h3>

    Doesnt work anymore in my template page.

    Here my full code for my older template in Coursepress 1:

    <?php if ( count( $instructors ) > 0 ) { ?>
    <div class="course-instructors right-content col-sm-4">
    <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
    <script>
    jQuery( function() {
    jQuery( "#instructor-profiles" ).accordion( {
    heightStyle: "content"
    } );
    } );
    </script>
    <div id="instructor-profiles">
    <?php
    foreach ( $instructors as $instructor ) {
    ?>

    <h3><?php echo $instructor->display_name; ?></h3>

    <?php
    $doc = new DOMDocument();
    $doc->loadHTML( get_avatar( $instructor->ID, 235 ) );
    $imageTags = $doc->getElementsByTagName( 'img' );

    foreach ( $imageTags as $tag ) {
    $avatar_url = $tag->getAttribute( 'src' );
    }
    ?>

    <div>
    <img src="<?php echo $avatar_url; ?>" />
    <?php $currentlang = get_bloginfo('language');
    if($currentlang=="pt_BR"):?>
    <p>
    <?php echo get_the_author_meta( 'cv_prof_br', $instructor->ID, 50 ); ?>
    </p>
    <p>
    <?php $maisinfo = get_the_author_meta( 'info_br', $instructor->ID, 50 ); ?>
    <?php elseif($currentlang=="en-US"):?>
    <p>
    <?php echo get_the_author_meta( 'cv_prof_us', $instructor->ID, 50 ); ?>
    </p>
    <p>
    <?php $maisinfo = get_the_author_meta( 'info_us', $instructor->ID, 50 ); ?>
    <?php else: ?>
    <p>
    <?php echo get_the_author_meta( 'cv_prof', $instructor->ID, 50 ); ?>
    </p>
    <p>
    <?php $maisinfo = get_the_author_meta( 'info', $instructor->ID, 50 ); ?>
    <?php endif; ?>
    <?php echo do_shortcode($maisinfo); ?>
    <!-- <?php echo do_shortcode( '[show_more more="+info" less="- info"]' . $maisinfo . '[/show_more]' ); ?> --!>
    </p>
    </div>
    <?php } ?>
    </div>

    </div><!--course-instructors right-content-->

  • Nithin

    Hi Vivian,

    Hope you are doing good today. :slight_smile:

    Is that the full code? I don't see any arguments passed to the $instructor variable. Your template starts with:
    <?php if ( count( $instructors ) > 0 ) { ?>

    If the $instructors variable is empty, the if condition won't work. This could be the issue here, or I'm missing something here.

    Could you please enable support access, so that we could check the mentioned template, with the theme editor(Appearance > Editor) , and see what is being missed. You can grant access from WPMU DEV > Support > Support Access > Grant Access, or check this manual: http://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Please let us know once you enable access, so that we could get this sorted. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • Vivian

    The access is granted, but I would ask you please, to understand the full scenario that Im explaining here.

    First, I had a template with this code that still work with Cousepress1. It really works. But, when I'd upgraded to Coursepress2, I cant get this working.

    If you take a look in my custom template that is in written in my theme's root, you will see that I have right now 2 codes: the first part of the code is working to my PT_BR website that I had upgraded yet to Coursepress2.

    So you will see this conditional before the code:
    <?php $currentlang = get_bloginfo('language');
    if($currentlang=="pt-BR"):?>
    <?php

    The second part is my old code current working for the others websites that still running under Coursepress 1.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.