Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Brandon Carnahan

Export WOO Members includes HTML

When exporting members and their plan from either the users page or member page the csv column contains both the plan and the html link. EG:
Plan
Yearly Membership (#5394)

We just want the plan only. Is there a setting for that?

4 weeks, 1 day ago
Tobias
Developer

There is not an option to strip HTML from the exported value. But here is a code snippet you can use in your theme:

/**
 * Example on how to strip HTML from the exported value
 *
 * @param string    $value
 * @param AC\Column $column
 *
 * @return string
 */
function ac_column_export_value_strip_html( $value, AC\Column $column ) {

	// Check for a custom field column
	if ( $column instanceof ACP\Column\CustomField ) {

		// The meta key you want the HTML stripped from
		$meta_key = 'my_custom_field_key';

		if ( $meta_key === $column->get_meta_key() ) {

			// Strips all HTML.
			// Example: '<a href="#">my label</a>' will become 'my label'.
			$value = strip_tags( $value );
		}
	}

	return $value;
}

add_filter( 'ac/export/value', 'ac_column_export_value_strip_html', 10, 2 );

There are more code examples available on our documentation page: Hooks: Actions & Filters.

4 weeks, 1 day ago
Brandon Carnahan

That works for the meta key, ,like the last 3 right columns in the screenshot, but not the Active Membership column. That one needs to be stripped of HTML, on export, like the username or email address is.

See screenshot, let me know if you have any ideas.

Screenshot

4 weeks, 1 day ago
Stefan
Developer

This snippet uses the same hook to strip the tags for all original (not ours) columns.
You can make it more specific by targeting the column for its name. The name can be displayed on our settings page by enabling it in the screen options menu.

function ac_column_export_value_strip_html( $value, AC\Column $column ) {
	// $column->get_name()
	if ( $column->is_original() ) {
		$value = strip_tags( $value );
	}

	return $value;
}

add_filter( 'ac/export/value', 'ac_column_export_value_strip_html', 10, 2 );
4 weeks, 1 day ago
Tobias
Developer

If you want to target a specific column you can use the AC\Column::get_name() method. Our documentation explains how to find the column name.

3 weeks, 4 days ago

You must be logged in to reply to this topic.