Skip to:

Filter gifts by user

  • navyspitfire


    I’m using an older gifts plugin with buddypress to allow users to send gifts to each other. I’m currently trying to make it so if you’re logged in, you can see all the gifts you’ve been gifted, while if I go to someone’s page, I will only see the gifts I gifted them.

    I’ve pasted my code below. Logically to me this makes sense; each <li> is a different gift from a user. I am trying to make it so if the returned result has the same id as the current user, display that <li>. I am beginning to think I am on the wrong file (before anyone says not to edit plugin files, this plugin has deprecated 2 years already).

    Any idea?

    global $wpdb;
    global $bp;
    $cur_user = $bp->loggedin_user->id;
    $profile_user = $bp->displayed_user->id;
    $result = $wpdb->get_results("SELECT * FROM wp_bp_activity WHERE item_id=" . $profile_user . " AND component='gifts'");
    <ul id="activity-stream" class="activity-list item-list" style="list-style-type: none;">
    	<?php //loop through ID's
    	foreach ($result as $results) {	?>
    		<?php while ( bp_activities() ) : bp_the_activity(); ?>
    		<?php if ( $results->user_id == $cur_user ) { ?>
    			<li class="<?php bp_activity_css_class(); ?> message" id="activity-<?php bp_activity_id(); ?>">...</li>
    		<?php } //end if
    	} //end foreach
Viewing 2 replies - 1 through 2 (of 2 total)

  • danbp


    You’re wrong and it is not a BP question.
    If you’re not comfortable with coding, i would at your place use a working plugin instead of trying to customize something i don’t completely understand.

    There is a similar one called Compliments (and up to date). Will be easier (perhaps) to adapt or even use as is for your needs ? 😉



    Ah thanks @danbp. I’ve put a lot of work into this and have done a lot of custom work already using this plugin, I’m just right at the end and can’t figure out this last issue.

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