Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • Solved adding a new action activity.
    Still curious to know if there is a way to add the default one instead of creating a new one.


    Sergio De Falco
    Participant

    @sgr33n

    replace code with `


    Sergio De Falco
    Participant

    @sgr33n

    Thanks Paul, I made it :), it’s something really rough, but if somebody needs it here it is:

    <?php
    
    // parametri del database
    $db_host = "localhost";         //Your database host
    $db_user = "database";          //Your database username
    $db_password = "password";      //Your database password
    $db_name = "database_01";       //Your database name
    
    $db = mysql_connect($db_host, $db_user, $db_password);
    set_time_limit(0);
    
    if ($db == FALSE)
    die ("Connection Error.");
    
    mysql_select_db($db_name, $db)
    or die ("Database Error.");
    
    $n = 0;
    $query = "SELECT * FROM <code>wp_posts</code> WHERE post_type = 'topic' OR post_type = 'reply' ORDER BY post_date ASC";
    
    $result = mysql_query($query, $db);
    
    while ($row = mysql_fetch_array($result))
    
    	{
    		unset($user_id);
    		unset($reg);
    		unset($guid);
    		unset($id);
    		unset($post_parent);
    		unset($post_date);
    		unset($nicename);
    		unset($displayname);
    		unset($title);
    		unset($forum);
    		unset($forumurl);
    		unset($post_type);
    		unset($forum_id);
    		unset($acttype);
    	
    		$user_id = $row['post_author'];
    		$guid = $row['guid'];
    		$reg = $row['user_registered'];
    		$id = $row['ID'];
    		$post_parent = $row['post_parent'];
    		$post_date = $row['post_date'];
    		$title = $row['post_title'];
    		$content = $row['post_content'];
    		$post_type = $row['post_type'];
    		$forum_id = $post_parent;
    		
    		$q1 = "SELECT * FROM <code>wp_users</code> WHERE ID = '$user_id'";
    		$r1 = mysql_query($q1, $db);
    		$e1 = mysql_fetch_array($r1);
    		
    		$nicename = $e1['user_nicename'];
    		$displayname = $e1['display_name'];
    		
    		if ( $post_type == 'reply' ) {
    			$q1 = "SELECT * FROM <code>wp_posts</code> WHERE ID = '$post_parent'";
    			$r1 = mysql_query($q1, $db);
    			$e1 = mysql_fetch_array($r1);
    			
    			$post_parent = $e1['post_parent'];
    			$title = $e1['post_title'];
    			$guid = $e1['guid'];
    		}
    		
    		$q1 = "SELECT * FROM <code>wp_posts</code> WHERE ID = '$forum_id'";
    		$r1 = mysql_query($q1, $db);
    		$e1 = mysql_fetch_array($r1);
    		
    		$forum = $e1['post_title'];
    		$forumurl = $e1['guid'];
    
    		if ( $post_type == 'topic' ) {
    			$action = mysql_real_escape_string('<a href="http://www.yoursite.com/users/' . $nicename . '/" rel="nofollow">' . $displayname . '</a> ha iniziato la discussione <a href="' . $guid . '">' . $title . '</a> nel forum <a href="' . $forumurl . '">' . $forum . '</a>');
    			$acttype = 'bbp_topic_create';
    		} else {
    			$action = mysql_real_escape_string('<a href="http://www.yoursite.com/users/' . $nicename . '/" rel="nofollow">' . $displayname . '</a> ha risposto alla discussione <a href="' . $guid . '">' . $title . '</a> nel forum <a href="' . $forumurl . '">' . $forum . '</a>');
    			$acttype = 'bbp_reply_create';
    		}
    		
    		$content = mysql_real_escape_string( $content );
    
    		if ( $user_id > 0 ) {
    			$q1 = "SELECT COUNT(umeta_id) AS conto FROM <code>wp_usermeta</code> WHERE user_id = '$user_id' AND meta_key = 'last_activity'";
    			$r1 = mysql_query($q1, $db);
    			$e1 = mysql_fetch_array($r1);
    			
    			if ( $e1['conto'] > 0 ) {
    				$q = "UPDATE wp_usermeta SET meta_value = '$post_date' WHERE user_id = '$user_id' AND meta_key = 'last_activity'";
    				mysql_query($q, $db);
    			} else {
    				$q = "INSERT INTO <code>wp_usermeta</code> (<code>umeta_id</code>, <code>user_id</code>, <code>meta_key</code>, <code>meta_value</code> ) VALUES ( NULL, '$user_id', 'last_activity', '$post_date' );";
    				mysql_query($q, $db);
    			}
    		}
    		
    		$q = "INSERT INTO <code>wp_bp_activity</code> (<code>id</code>, <code>user_id</code>, <code>component</code>, <code>type</code>, <code>action</code>, <code>content</code>, <code>primary_link</code>, <code>item_id</code>, <code>secondary_item_id</code>, <code>date_recorded</code>, <code>hide_sitewide</code>, <code>mptt_left</code>, <code>mptt_right</code>, <code>is_spam</code> ) VALUES ";
    		$q .= "(NULL, '$user_id', 'bbpress', '$acttype', '$action', '$content', '$guid', '$id', '$post_parent', '$post_date', '0', '0', '0', '0')";
    		mysql_query($q, $db);
    
                    $n++;
    	}
    
    mysql_close($db);
    
    echo "Done! inserted $n activity entries";
    ?>
    

    The action is in italian, you can modify as you want

    @djpaul please help me solving this :P I see that you managed some trac tickets about something similar, maybe bp_is_component_front_page is the key?

    Thanks :)

    Right paul,

    How can I correct this?
    Wanna look at the code?

    42 years, 8 months ago is timestamp 0, maybe the value passed was not an integer or something broke up.

    Here it is the full function (untested):

    function bpdev_get_birthday_from_dob($dob_field_name,$user_id=false){
    if(!$user_id)
    $user_id=bp_displayed_user_id ();

    $dob_time=xprofile_get_field_data($dob_field_name, $user_id);//get the datetime as myswl datetime

    $dob=new DateTime($dob_time);//create a DateTime Object from that

    return $dob->format(‘F, d’);
    }

    Paul, anyway it’s pretty simple to use both methods. We know that default wp_users support first_name, last_name, nickname and description (bio). Maybe you could make possibile to modify each of that from buddypress (i made it in my theme) and make a base group with these fields. Then if administrators want to add more fields and groups you could populate xprofile table. In this way you could have a more deep integration into WordPress.

    Sorry if I asked something already answered :P

    Same as before but:

    echo $dob->format(‘F, d’);

    Cool :) so a more deep integration into the wordpress core… Speaking of This, i’m just wondering why buddypress doesn’t use user_metadata and have a proprietary xprofile table.

    Guess that’s for the spam control. So that’s why the DB needed to upgrade, I see it already on the current SVN.

    Thanks Paul :)

    Here they are :P
    These improvements will affect the database structure?

    Thanks :)

Viewing 13 replies - 1 through 13 (of 13 total)
Skip to toolbar