Skip to:
Content
Pages
Categories
Search
Top
Bottom

custom post type in bbpress forum board


  • pinballnate
    Participant

    @pinballnate

    Hi, I used the JetEngine Profile Builder to create some custom fields that I want to use in my discussion boards. They are both stored in the User Settings post type. one is a text field (neighborhood) and the other is a media field (profile-picture).
    I would like for the neighborhood meta field to appear after the user name when they post and would like the profile-picture to show up where their avatar is.
    Is there a way or a plug-in that would achieve this? I tried BBP Profile Information, but there does not seem to be a way to map or link my custom fields.

    Any help would be greatly appreciated!

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

  • Robin W
    Moderator

    @robin-w

    are you sure it is stored in a custom post, not in usermeta?

    and if in custom post, how is each user stored?


    pinballnate
    Participant

    @pinballnate

    Hi Robin, You are correct – it is in usermeta.


    Robin W
    Moderator

    @robin-w

    ok, so do you know how to amend files and ftp them to your site?


    pinballnate
    Participant

    @pinballnate

    I don’t, but I can learn.


    Robin W
    Moderator

    @robin-w

    find
    wp-content/plugins/bbpress/templates/default/bbpress/loop-single-reply.php

    transfer this to your pc and edit

    before line 56 which says

    <?php do_action( 'bbp_theme_after_reply_author_details' ); ?>

    add the following

    <?php echo 'hello' ; ?>

    and save

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/loop-single-reply.php

    bbPress will now use this template instead of the original

    You should now see ‘hello’ where you want the neighborhood field

    If you get this far, then come back


    pinballnate
    Participant

    @pinballnate

    I will get to work on it, thanks.


    pinballnate
    Participant

    @pinballnate

    OK – so far so good.


    Robin W
    Moderator

    @robin-w

    great, so now I need to know the names of the fields you want in the database

    so I need to construct a bit of code that looks like

    $neighborhood = get_user_meta ($user_id, ‘%what_the_field_is_called%’ , true) ;

    so I need %what_the_field_is_called% for both field 🙂


    pinballnate
    Participant

    @pinballnate

    The avatar field is profile-picture
    The neighborhood field is user-subdivision


    Robin W
    Moderator

    @robin-w

    ok replace the

    <?php echo 'hello' ; ?>

    with

    <?php 
    $neighborhood = get_user_meta (get_current_user_id(),  'user-subdivision' , true) ;
    echo '<li>'.$neighborhood.'</li>' ;
    ?>

    and let’s see if that does that one first


    Robin W
    Moderator

    @robin-w

    for the avatar, I need to know what is stored in the usermeta, so can you try adding this after line 44

    <?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>

    to get

    <?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>
    <?php 
    $avatar = get_user_meta (get_current_user_id(),  'profile-picture' , true) ;
    echo '<li>'.$avatar.'</li>' ;
    ?>

    I need to see if this produces a url or link to media item etc.


    pinballnate
    Participant

    @pinballnate

    I’m not sure what is wrong – it is not changing anything. The funny thing is, it still says hello. I checked in the file manager to make sure the file was changed and it is. I cleared the cache on the website and cleared my browsing data. Even when I write a new reply, it still says hello.


    pinballnate
    Participant

    @pinballnate

    I will start over and see how it goes.


    pinballnate
    Participant

    @pinballnate

    My problem was I put the file back in the bbpress directory instead of the theme directory. Here are the results: after instructions
    You can see the page here: http://www.staging8.commercecitynorth.com/forums/topic/a-discussion-board-is-such-a-good-idea/


    pinballnate
    Participant

    @pinballnate

    The neighborhood is showing up, the thing is though – it is the current logged in users neighborhood, not the person who posted.


    Robin W
    Moderator

    @robin-w

    oops sorry, I’ll correct that


    Robin W
    Moderator

    @robin-w

    try

    <?php 
    $neighborhood = get_user_meta (bbp_get_reply_author_id(),  'user-subdivision' , true) ;
    echo '<li>'.$neighborhood.'</li>' ;
    ?>

    come back if that doesn’t work


    Robin W
    Moderator

    @robin-w

    ok, can you change the other one to

    <?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>
    <?php 
    $avatar = get_user_meta (bbp_get_reply_author_id(),  'profile-picture' , true) ;
    echo '<li>herestart'.$avatar.'hereend</li>' ;
    ?>

    pinballnate
    Participant

    @pinballnate

    The neighborhood works. the image does not: bbpress


    Robin W
    Moderator

    @robin-w

    that’s fine, I wanted to see what was in the database ie in this case 1345, I suspect it is a reference to a media image


    Robin W
    Moderator

    @robin-w

    ok, so we are making progress.

    I don’t expect this to work, just to return the next stage

    so amend that to

    <?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>
    <?php 
    $image_id = get_user_meta (bbp_get_reply_author_id(),  'profile-picture' , true) ;
    $image = get_post_meta ($image_id, _wp_attached_file, true)
    echo '<li>herestart'.$image.'hereend</li>' ;
    ?>

    pinballnate
    Participant

    @pinballnate

    that didn’t seem good?
    bbpress


    Robin W
    Moderator

    @robin-w

    oops semi colon missing from $image = line

    <?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>
    <?php 
    $image_id = get_user_meta (bbp_get_reply_author_id(),  'profile-picture' , true) ;
    $image = get_post_meta ($image_id, _wp_attached_file, true) ;
    echo '<li>herestart'.$image.'hereend</li>' ;
    ?>
Viewing 23 replies - 1 through 23 (of 23 total)
  • You must be logged in to reply to this topic.
Skip to toolbar