Jobs & Experts with MyCred Badges using shortcode

Greetings,

I am using the shortcode [mycred_my_badges] for displaying MyCred Badges, the problem is it outputs Jobs & Experts' buttons along with what appears to be broken code, as seen in the attached image. It doesn't matter where I place the shortcode it continues to happen. How can I fix this?

Thank-you, kindly.

  • Adam Czajczyk
    • Support Gorilla

    Hello Daisy,

    I hope you're well today and thank you for your question!

    I've just tried to replicate this on my own setup but with no luck. That said, the fastest "workaround" would be to hide Jobs & Experts buttons with CSS code:

    .jbp-shortcode-button {display:none;}

    This would however hide these buttons everywhere on your site which is not a requested behavior, I suppose.

    Having said that, I'd like to ask you whether the issue appears on each and every post/page that you use myCRED shortcode, regardless whether it's J&E page or not?

    I would also like to take a closer look at your site so could you please grant me a support access to your dashboard? To do this, please follow the guide at an URL below and let me know when you're ready:

    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Thanks,
    Adam

  • Adam Czajczyk
    • Support Gorilla

    Hello Daisy,

    Thanks for granting an access!

    I've visited your site's dashboard and I've noted that you're using a Visual Composer. Unfortunately, it's known for breaking shortcodes sometimes.

    I've added a /wpmu-test/ page to your site and added the [mycred_my_badges] shortcode there. Take a look please: there's no any "broken code", neither there's a Job&Expert shortcode.

    I think the clue here is to add shortcodes via a standard WP editor switched to "Text" mode and make sure that all the ' and " (apostrophes and quotation marks) are "in pairs" (so if there's an opening one, there should also be closing one).

    I've spotted a broken shortcode on your homepage (/vc_row]) as well so I'd suggest going through all the pages/posts and double-checking all shortcodes agains what I wrote above.

    In case you'd need further assistance with this, just let me know and also provide me please with an explicit link to the page in your initial question.

    Cheers,
    Adam

    • Daisy
      • Flash Drive

      Hi Adam,

      I am not sure if you received my last thread comment being that I didn't 'Reply'. So here is my previous message:

      I am aware of some of the broken shortcodes. For some reason it gets altered when updating the editor page. Every so often I do go through and correct it, like you mentioned via 'Text' mode. However, I do have the problem when all is in order. I notice the error does not occur on all the pages, for example the test page you created nor the homepage.

      It happens particularly on the /wp-content/plugins/jobs_plus/app/views/expert-single.php, I have included another MyCred shortcode <?php echo do_shortcode('[mycred_custom_shortcode]'); ?> within the template without any issue, however, it does get the issue when using [mycred_my_badges] the issue also happens if I add the shortcode manually to the Experts (now titled Creators) profile via the Admin.

      I sent you FTP access for a closer look. It is important the badges to show correctly, as it is intended to show the Expert's achievements.

      Thank you.

  • Daisy
    • Flash Drive

    Thank-You Adam,

    I am aware of some of the broken shortcodes. For some reason it gets altered when updating the editor page. Every so often I do go through and correct it, like you mentioned via 'Text' mode. However, I do have the problem when all is in order. I notice the error does not occur on all the pages, for example the test page you created nor the homepage.

    It happens particularly on the /wp-content/plugins/jobs_plus/app/views/expert-single.php, I have included another MyCred shortcode <?php echo do_shortcode('[mycred_custom_shortcode]'); ?> within the template without any issue, however, it does get the issue when using [mycred_my_badges] the issue also happens if I add the shortcode manually to the Experts (now titled Creators) profile via the Admin.

    I sent you FTP access for a closer look. It is important the badges to show correctly, as it is intended to show the Expert's achievements.

    Thank you.

  • Adam Czajczyk
    • Support Gorilla

    Hello Daisy,

    I hope you're having a nice day and thanks for follow up!

    I have received your e-mail. Usually, I'd respond having a ready solution but this one I'll have to consult with with one of my "more coding aware" colleagues and since you're worrying about being still assisted on this I'd like to assure you that you are.

    I'll keep you updated here as soon as possible!

    Thank you for your patience!
    Cheers,
    Adam

  • Daisy
    • Flash Drive

    Greetings,

    I am still trying to resolve this issue. MyCred has assisted me and things are starting to look good, however, there is still one thing. I need for the badges to show the badges of the expert that is being viewed and not the badges of the logged-in user. MyCred message was as follow:

    example:

    echo do_shortcode( ‘[mycred_my_badges user_id=“‘ . $profile_id . ‘“]’ );

    You would need to provide the users numeric ID (in the above example via the $profile_id variable.
    ........

    * When using the snippet, the page goes blank on the Expert's profile. Could you provide me with a snippet that will allow for the Profile Id to pass, or anything else that will work?

    Note: I am already using the following custom shortcode for MyCred Points (within function.php), and this is working great, but I need the badges to do the same.

    // Add Shortcode
    function custom_shortcode() {
    global $post;

    echo mycred_get_users_cred( $post->post_author );

    }
    add_shortcode( 'mycred_custom_shortcode', 'custom_shortcode' );

  • Adam Czajczyk
    • Support Gorilla

    Hello Daisy!

    MyCred has assisted me and things are starting to look good,

    This is a great news! I guess it was a bit easier for them as they do know their plugin's code "inside out".

    As for the remaining issue.

    A word of advise, if you don't mind: any shortcode functions shouldn't ever "echo" content directly, instead it wold be better to use "return" as it will work the same way here but will not break anything. That said, your current snippet could look like this:

    // Add Shortcode
    function custom_shortcode() {
    global $post;
    
    return mycred_get_users_cred( $post->post_author );
    
    }
    add_shortcode( 'mycred_custom_shortcode', 'custom_shortcode' );

    This is however just a side not, I hope you don't mind that :slight_smile:

    I need for the badges to show the badges of the expert that is being viewed and not the badges of the logged-in user.

    The code they gave you should be used inside a page template. I've also adjusted it a bit replacing apostrophes with single quotation marks (which probably has resulted in site going blank). That said, adding this anywhere inside a template of the page/post inside WP loop should work:

    echo do_shortcode( '[mycred_my_badges user_id=“' . $post->post_author . '“]' );

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.