Skip to:
Content
Pages
Categories
Search
Top
Bottom

adding shortcodes to members header from a different plugin


  • alexfads
    Participant

    @alexfads

    Hello. I am currently trying to combine buddypress with some of the functionality/options of a plugin called userpro. Userpro is completely done with shortcodes. My goal is to add the profile options from a shortcode to the members-header.php, so that when a user visits their profile or someone elses profile,they still see all of the cool tabs provided by buddypress, but the header is changed to the header that exists from using the shortcode. Ive tried to research past topics regarding the members-header.php, but have only recently figured out that shortcodes aren’t parsed with bp. However, I saw a post briefly explain that in order to add shortcodes to .php files, i have to add a filter to a function. So, i was wondering if anyone could guide me to the members-header function (or the correct function for that matter) and/or the correct filter to add to this function…? I think it will or is supposed to look something like this :

    function extra_profile_fields_output(){
    global $bp;

    $field_text = bp_get_profile_field_data( ‘field=Country’ ) );
    echo ‘<span class=”profile-fields”>’ .$field_text. ‘</span>’;
    }
    add_action( ‘bp_profile_header_meta’, ‘extra_profile_fields_output’ )

    If anyone can either explain or guide me to a tutorial that can help me understand how to allow shortcodes in the buddypress template files, I would greatly appreciate any insight. I apologize in advance for any of the above being not clear or sounding ignorant. I am new, and Im just trying to learn as i go. I understand where to find the template files, I just dont understand how to create the proper function/filter that would provide the needed functionality, even if its just an example, I can atleast play around from there. I figure the more I break it, the more im learning anyway right? Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)

  • shanebp
    Moderator

    @shanebp

    In your theme, create an over-ride this file:
    buddypress\bp-templates\bp-legacy\buddypress\members\single\member-header.php

    Read this re over-riding files:

    Theme Compatibility & Template Files

    Add your shortcodes by using:
    https://codex.wordpress.org/Function_Reference/do_shortcode


    alexfads
    Participant

    @alexfads

    Thanks @shanebp. I had this already written: <?php echo do_shortcode(‘[userpro template=view]’); ?>, but now im just not understanding where to put it, and if im missing something else as far as the “filter” goes. I first attempted to add <?php echo do_shortcode(‘[userpro template=view]’); ?> to the member-header.php file, somewhere right above this: <?php
    /***
    * If you’d like to show specific profile fields here use:
    * bp_member_profile_data( ‘field=About Me’ ); — Pass the name of the field
    */
    do_action( ‘bp_profile_header_meta’ );

    ?>

    but that didnt work. so then i did some more research and thats where i read that BP doesnt parse shortcodes and i would have to either make a function and add a filter that would allow shortcodes, or add a filter to an already exsisting function (which i was assuming was the bp_profile_header_meta’) that would allow shortcodes. Well, then of course being a newbie, i got lost looking at all of the codex stuff regarding functions parameters and return values, it all kind of went over my head, and couldnt figure out where to start anymore so i gave up. I dont have the means to hire a developer at this point, so ill just have to keep doing research until i figure out this filter function shortcode stuff, lol. Anyway, if you have any other ideas or ways i might be able to figure this out im all ears, otherwise, i genuinely appreciate your help. It’s hard to come across developers that are ok with sharing knowledge and help us newbies, so i thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘adding shortcodes to members header from a different plugin’ is closed to new replies.
Skip to toolbar