Deprecated

This function has been deprecated. Use @see ap_activity_add(). Activities are inserted in ap_activity table instead.

ap_update_post_activity_meta( object|integer $post, string $type, integer $user_id, boolean $append_to_question = false, boolean|string $date = false )

Description #

Update post activity meta.

Parameters #

  • $post
    object | integer (Required) Question or answer.
  • $type
    string (Required) Activity type.
  • $user_id
    integer (Required) ID of user doing activity.
  • $append_to_question
    boolean (Optional) Append activity to question. Default value: false
  • $date
    boolean | string (Optional) Activity date in mysql timestamp format. Default value: false

Changelog #

VersionDescription
4.1.2Use @see ap_activity_add(). Activities are inserted in ap_activity table.
2.4.7Introduced.

Source #

File: includes/qameta.php

function ap_update_post_activity_meta( $post, $type, $user_id, $append_to_question = false, $date = false ) {
	if ( empty( $post ) ) {
		return false;
	}

	if ( false === $date ) {
		$date = current_time( 'mysql' );
	}

	$post_o   = ap_get_post( $post );
	$meta_val = compact( 'type', 'user_id', 'date' );

	// Append to question activity meta. So that it can shown in question list.
	if ( 'answer' === $post_o->post_type && $append_to_question ) {
		$_post         = ap_get_post( $post_o->post_parent );
		$meta          = $_post->activities;
		$meta['child'] = $meta_val;
		ap_update_post_activities( $post_o->post_parent, $meta );
	}

	return ap_update_post_activities( $post_o->ID, $meta_val );
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment