Skip to:
Content
Pages
Categories
Search
Top
Bottom

changing forum role output


  • s1r0n
    Participant

    @s1r0n

    on the forums a post includes username, role (like keymaster, participant, etc.). I want to be able to change the role to something i decide, like for example the “group” the user is a member of. Where file can I get at that in, what filter do I use, what function do I override, what action do I take. I’m assuming i don;t have to hard code the change.

    you can see what I’m talking about on this. I need to change Key Master, participant, etc.

    http://thelightningpath.com/forum/forums/topic/wave-two-moon-card-question/#post-1838

    thanks in advance

Viewing 8 replies - 1 through 8 (of 8 total)
  • You could use this plugin https://wordpress.org/plugins/bbpress-string-swap/

    Or you can use this plugin https://gist.github.com/ntwb/7864894

    Or just add the code from the plugin to your themes functions.php or bbpress-functions.php file.

    add_filter( 'bbp_get_dynamic_roles', 'ntwb_bbpress_custom_role_names' );
    
    function ntwb_bbpress_custom_role_names() {
    	return array(
    
    		// Keymaster
    		bbp_get_keymaster_role() => array(
    			'name'         => 'My Custom Keymaster Role Name',
    			'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() )
    		),
    
    		// Moderator
    		bbp_get_moderator_role() => array(
    			'name'         => 'My Custom Moderator Role Name',
    			'capabilities' => bbp_get_caps_for_role( bbp_get_moderator_role() )
    		),
    
    		// Participant
    		bbp_get_participant_role() => array(
    			'name'         => 'My Custom Participant Role Name',
    			'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() )
    		),
    
    		// Spectator
    		bbp_get_spectator_role() => array(
    			'name'         => 'My Custom Spectator Role Name',
    			'capabilities' => bbp_get_caps_for_role( bbp_get_spectator_role() )
    		),
    
    		// Blocked
    		bbp_get_blocked_role() => array(
    			'name'         => 'My Custom Blocked Role Name',
    			'capabilities' => bbp_get_caps_for_role( bbp_get_blocked_role() )
    		)
    	);
    }

    s1r0n
    Participant

    @s1r0n

    HI Stephen, thanks for the reply. this is not what I want to do though. I don’t want the role names to appear in the profile, I want my “group” names to appear. Since these groups are not mapped to role names, I can’t map them using these functions you provide. I need something that hooks right into the output. maybe this requires me to hardmodify the template?

    I’m not entirely following what it is your trying to achieve, in your original post you wrote

    I want to be able to change the role to something i decide, like for example the “group” the user is a member of…

    …you can see what I’m talking about on this. I need to change Key Master, participant, etc

    If you need to change these names ‘Keymaster’, ‘Participant’ etc these are the role names that are defined by the names of your user roles.

    And now you write

    this is not what I want to do though. I don’t want the role names to appear in the profile, I want my “group” names to appear.

    What ‘group’ names, are you talking about BuddyPress groups?, if not what plugin are you using to assign users to groups?

    Your example link shows nothing obvious to me about any ‘group’


    s1r0n
    Participant

    @s1r0n

    Hi, sorry about being so obtuse.

    I’m using woocommerce groups. it stores its stuff in several non-standard wordpress tables. I need to be able to replace the bbpress roles as displayed in the forum iteration with the group the user is assigned to. I want to be able to do that without hacking the core, for obvious reasons.

    does this help.

    m

    Follow the steps to copy the template files that you need to customize as per this:

    https://codex.bbpress.org/theme-compatibility/

    Primarily it will be loop-single-reply.php but you will need to look at a few of the other templates also.

    Before Line #45:
    <?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => true ) ); ?>
    After Line #45:
    <?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => false ) ); ?>

    Around that same area in that file you will want call whatever WooCommerce function you need to display the users group.

    eg. <div><?php woo_user_group( userid() ); ?></div>
    (I have no idea what functions WooCommerce use)


    s1r0n
    Participant

    @s1r0n

    that worked like a charm. thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


    s1r0n
    Participant

    @s1r0n

    Stephen, while I got your attention.

    is there a hook to get access to bbpress posts as they are submitted into the database, similiar to wordpress hooks like wp_insert_post_data, where I can get access to the post body and alter it?


    s1r0n
    Participant

    @s1r0n

    i don’t know why this one was so hard for the support people to answer, but the hook I was looking for was

    add_filter( 'bbp_get_reply_content', 'lp_access_enforcement', 99,2);

    this allows me to take the content just before it is posted on the screen and manipulate it how I want. now my forums here

    http://thelightningpath.com/forum/subject/the-need-for-spirit-to-sustain-a-growing-baby/

    can be locked down. people now need to pay for a subscription to get access to certain forums on my site.

    i’m posting this for anybody else that might want to expand on bbpress’s limited access functionality.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar