Reply To: Infinite loop on reply update
because i cant edit my reply my correction:
function bbp_update_reply_position( $reply_id = 0, $reply_position = 0 ) {
global $wpdb;
// Bail if reply_id is empty
$reply_id = bbp_get_reply_id( $reply_id );
if ( empty( $reply_id ) )
return false;
// If no position was passed, get it from the db and update the menu_order
if ( empty( $reply_position ) ) {
$reply_position = bbp_get_reply_position_raw( $reply_id, bbp_get_reply_topic_id( $reply_id ) );
}
$db_menu_order = $wpdb->get_var("select menu_order from {$wpdb->posts} where ID={$reply_id}");
if($db_menu_order == $reply_position)
return (int) $reply_position;
// Update the replies' 'menp_order' with the reply position
wp_update_post( array(
'ID' => $reply_id,
'menu_order' => $reply_position
) );
return (int) $reply_position;
}