WordPress.org

Support

Support » How-To and Troubleshooting » overriding code in theme

overriding code in theme

  • Robin W

    @robin-w

    bbPress.org Moderator

    Ok, so I have written and got working my first plugin, I am adding some user info to the reply display in bbpress.

    It has the following lines in one of its php files (loop-single-reply)

    <?php do_action( 'bbp_theme_before_reply_author_details' ); ?>
    <?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => true) ); ?>
    [...other lines of code here]
    
    <?php do_action( 'bbp_theme_after_reply_author_details' ); ?>

    I worked out how to get a plugin to put some other stuff I need before ‘bbp_theme_after_reply_author_details’ so it’s working fine

    BUT I want to change the line

    <?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => true) ); ?> to
    <?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => false) ); ?>
    I think I do this with a “remove action” in my plugin, and then add the code line as I want it back into my plugin – in effect deleting the line between “do actions” and replacing this with what I want.

    But I cannot fathom from the codex and other googles quite how you do this

    1) is my understanding correct?
    2) what would the code line be in my plugin?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    I just saw your question. Pretty new at this.

    You can’t use a remove action to remove lines in a template.

    But I think that you could be able to do what you want using the bbp_after_get_reply_author_link_parse_args filter.

    It is called in the bbp_get_reply_author_link function, via the bbp_parse_args function :

    $r = bbp_parse_args( $args, array(
    			'post_id'    => 0,
    			'link_title' => '',
    			'type'       => 'both',
    			'size'       => 80,
    			'sep'        => '&nbsp;',
    			'show_role'  => false
    		), 'get_reply_author_link' );

    So in your plugin, you could simply override the ‘show_role’ to false.

    Robin W

    @robin-w

    bbPress.org Moderator

    Thanks for that – I’ll give it a try

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘overriding code in theme’ is closed to new replies.