Documentation

Didn't find anything? Ask your questions in the forum.
Documentation Professionals Overwrite or extend Helpful filters and actions

Overwrite or extend Helpful filters and actions

With version 4.0.0 Helpful got some hooks to extend Helpful with. You can read which hooks are available now here.

/**
 * Here you can add your own themes to Helpful.
 */
add_filter( 'helpful_themes', 'custom_themes' );
function custom_themes( $themes ) {
	
	$themes[] = [
		'id'         => 'custom',
		'label'      => esc_html_x( 'Custom', 'theme name', 'helpful' ),
		'stylesheet' => 'STYLESHEET_URL',
	];

	return $themes;
}

/**
 * Here you can generate your own ID for your users. By default,
 * a unique random string is created. This ID is automatically stored
 * in a cookie or a session, depending on what is currently working.
 */
add_filter( 'helpful_user_string', 'custom_user_string' );
function custom_user_string() {
	return 'unique_user_id';
}

/**
 * This text is always displayed before the feedback form
 * as soon as the feedback form is output by Helpful.
 */
add_action( 'helpful_before_feedback_form', 'custom_before_feedback_form' );
function custom_before_feedback_form() {
	echo 'This is shown before the feedback form.';
}

/**
 * This text is always displayed after the feedback form
 * as soon as the feedback form is output by Helpful.
 */
add_action( 'helpful_before_feedback_form', 'helpful_after_feedback_form' );
function helpful_after_feedback_form() {
	echo 'This is shown after the feedback form.';
}

/**
 * This is packed into the array for a feedback item in the backend.
 * The output is not taken into account, but for example a process can
 * be attached that is only executed if Feed
 */
add_filter( 'helpful_admin_feedback_item', 'custom_feedback_item' );
function custom_feedback_item( $item ) {
	return $item;
}

/**
 * This can be used to edit sent fields.
 */
add_filter( 'helpful_feedback_submit_fields', 'custom_submitted_fields' );
function custom_submitted_fields( $fields ) {
	return $fields;
}

/**
 * Allows you to edit the sent feedback message.
 */
add_filter( 'helpful_feedback_submit_message', 'custom_submitted_message' );
function custom_submittet_message( $message ) {
	return $message;
}

/**
 * Allows you to add your own tags. So you have the possibility to
 * use your tags in the admin area and display them in the text.
 */
add_filter( 'helpful_tags', 'custom_tags' );
function custom_tags( $tags ) {

	$tags['{custom}'] = 'My own tag that is replaced in the text.';

	return $tag;
}

/**
 * Allows you to set the default after a Helfpful installation.
 * These are used whenever Helpful is freshly installed.
 */
add_filter( 'helpful_options', 'custom_options' );
function custom_options( $options ) {
	return $options;
}

/**
 * Here you can add your own tabs to Helpful, which will then 
 * be shown in the admin area. However, you will need to create
 * your own page for this.
 */
add_filter( 'helpful_admin_tabs', 'custom_tabs' );
function custom_tabs( $tabs ) {

	$tabs['my_tab'] = [
		'href' => 'link to admin page',
		'name' => 'tab name',
	];

	return $tabs;
}

/**
 * Used to link own actions to a Helpful maintenance. The added
 * array always outputs the message. You can pack your own processes
 * into Helpful Maintenance here.
 */
add_filter( 'helpful_maintenance', 'custom_maintenance' );
function custom_maintenance( $defaults ) {

	$defaults[] = 'My own process that is executed during maintenance by Helpful.';

	return $defaults;
}

Was this post helpful?