Skip to:
Content
Pages
Categories
Search
Top
Bottom

show only if it applies to reply author


  • andrew55
    Participant

    @andrew55

    I’ve got a simple “php if snippet” I’m trying to get into loop-single-reply.php.

    Here is an example of my snippet (used for a seperate membership script):

    <?php
    require_once '/members/library/Am/Lite.php';
    $user = Am_Lite::getInstance()->getUser(); 
    ?>
    <?php
    if (Am_Lite::getInstance()->haveSubscriptions(364))
    {
    ?>
    <span class='custom-user-donation-badge'>I've Donated!</span>
    <?php
    }
    else {
    // do the other thing
    ?>
    <?php
    }
    ?>

    I need the code snippet to show only in the profile area of the reply author, if it applies to them.

    In other words: “show this if it applies and only show if it applies to this specific reply author.”

    I’ve used these before for something similar:

    $reply_user_id = bbp_get_reply_author_id();
    $reply_user = new WP_User( $reply_user_id )

    I’m still leaning php and bbpress. Any suggestions on how I can wrap my code snippet with these bbpress statements? This way, my code snippet will only apply if it applies to the specific author.

    Thanks for any suggestions.

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

  • andrew55
    Participant

    @andrew55

    I seems like this should work, but it doesn’t:

    <?php
    if (bbp_get_reply_author_id($reply_id))
    {
    ?>
    
    my other code goes here
    
    <?php
    }
    ?>

    It seems like it should wrap my code with a statement of “show only for the author of this reply” but it’s not working like this.

    Any suggestions on what the code would be to “just show for the author of this reply?”

    Thanks for any help.


    andrew55
    Participant

    @andrew55

    I don’t mean to ramble, but I think the solution will be something such as:

    if (Am_Lite::getInstance()->haveSubscriptions(364) && ($reply_user_id($topic_id) ))

    I just add bbpress statement to my already existing “if” statement using an “And” operator.

    I’m just getting caught up on the bbpress part.

    Any suggestions on what the bbpress code would be to “just show for the author of this reply?”

    Thanks for any help.


    andrew55
    Participant

    @andrew55

    OK, forget my additional code. Can someone please let me know what snippet (just for bbBress) to show something only in the profile area of the reply author, only if it applies to them.

    In other words: “show if it applies to this specific reply author.”

    I’ve edited loop-single-reply.php with great results for similar features.

    Thanks for any suggestions.


    Robin W
    Moderator

    @robin-w

    not exactly sure what you are after, but try this code and play with it

    put this in your functions file – you don’t need to alter any templates

    add_action ('bbp_theme_after_reply_author_details', 'rew_display');
    add_action ('bbp_theme_after_topic_author_details', 'rew_display'); 
    
    //main function to display
    function rew_display () {
    	global $reply_id ;
    	$author_id=bbp_get_reply_author_id( $reply_id ) ;
    	$user = Am_Lite::getInstance()->getUser(); 
    	$some_match = Am_Lite::getInstance()->haveSubscriptions(364))
    	if ($author == $user && $some_match == "hello" ) {
    		echo '<div class = "rew_display">' ;
    			echo '<ul>' ;	
    				echo '<li>' ;
    					echo "I've donated" ;
    				echo '</li>' ;
    			echo '</ul>' ;
    		echo '</div>' ;
    	}
    }

    Come back if I can help clarify


    andrew55
    Participant

    @andrew55

    thank you very much.

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