e107v1::callback_e107v1_userid( string $field )

Override the callback_user function in ‘converter.php’ for custom e107v1 imports


Description Description

A mini cache system to reduce database calls to user ID’s


Parameters Parameters

$field

(Required)


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/admin/converters/e107v1.php

	protected function callback_e107v1_userid( $field ) {

		// Strip only the user id from the topic and reply authors
		$field = preg_replace( '/(\d+?)+\.[\S\s]+/', '$1', $field );

		if ( ! isset( $this->map_userid[ $field ] ) ) {
			if ( ! empty( $this->sync_table ) ) {
				$row = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value = %s LIMIT 1", '_bbp_old_user_id', $field ) );
			} else {
				$row = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT user_id AS value_id FROM {$this->wpdb->usermeta} WHERE meta_key = %s AND meta_value = %s LIMIT 1", '_bbp_old_user_id', $field ) );
			}

			if ( ! is_null( $row ) ) {
				$this->map_userid[ $field ] = $row->value_id;
			} else {
				if ( true === $this->convert_users ) {
					$this->map_userid[ $field ] = 0;
				} else {
					$this->map_userid[ $field ] = $field;
				}
			}
		}
		return $this->map_userid[ $field ];
	}

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.