For the complete documentation index, see llms.txt
Saltar al contenido principal

Feedback widget for LearnDash

Add the PushFeedback widget in LearnDash, with options for automatic and custom widget placement.

Prerequisites​

  • A PushFeedback project. Copy its project ID from Projects > your project > Snippet and replace <YOUR_PROJECT_ID> in the examples.
  • Access to your LearnDash website in WordPress.

Installation​

Floating button​

  1. Access the admin dashboard of your LearnDash website by navigating to http://yourwebsite.com/wp-admin/.

  2. Open your child theme's functions.php. Use a child theme so updates preserve your changes.

  3. Add the following code at the end of your theme's functions.php file:

    function is_learn_dash_fullscreen() {
    return is_singular(array('sfwd-lessons', 'sfwd-quiz', 'sfwd-topic'));
    }

    function enqueue_pushfeedback_scripts_conditionally() {
    if (is_learn_dash_fullscreen()) {
    echo '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.css">';
    echo '<script type="module" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.esm.js"></script>';
    }
    }
    add_action('wp_head', 'enqueue_pushfeedback_scripts_conditionally');

    function inject_custom_feedback_widget($content) {
    static $widget_injected = false;
    if (is_learn_dash_fullscreen() && !$widget_injected) {
    $project_id = '<YOUR_PROJECT_ID>'; // Replace with your actual project ID

    $widget_html = '
    <feedback-button
    project="' . $project_id . '"
    button-style="dark"
    modal-position="bottom-right"
    button-position="bottom-right"
    >
    Share feedback
    </feedback-button>
    ';

    $widget_injected = true;
    return $content . $widget_html;
    }

    return $content;
    }
    add_filter('the_content', 'inject_custom_feedback_widget');

    Replace <YOUR_PROJECT_ID> with your project's ID from the PushFeedback dashboard.

  4. Save your changes.

  5. Open a LearnDash lesson, topic, or quiz and click Share feedback.

Feedback widget on a LearnDash lesson

Inline button​

Feedback button placed within page content

Use this alternative in place of the floating-button code in functions.php. Define the functions only once:

// Add this once to your theme's functions.php for the chosen mode.
add_action('wp_head', function () {
if (!is_singular(array('sfwd-lessons', 'sfwd-quiz', 'sfwd-topic'))) return;
echo '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.css">';
echo '<script type="module" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.esm.js"></script>';
});

add_filter('the_content', function ($content) {
if (!is_singular(array('sfwd-lessons', 'sfwd-quiz', 'sfwd-topic'))) return $content;
return $content . <<<'HTML'
<feedback-button project="<YOUR_PROJECT_ID>" button-position="default" modal-position="center" button-style="dark">Feedback</feedback-button>
HTML;
});

Replace <YOUR_PROJECT_ID> with your project ID. The widget appears after each lesson, topic, or quiz.

Embedded form​

Feedback form embedded directly in a page

Use this alternative in place of the floating-button code in functions.php. Define the functions only once:

// Add this once to your theme's functions.php for the chosen mode.
add_action('wp_head', function () {
if (!is_singular(array('sfwd-lessons', 'sfwd-quiz', 'sfwd-topic'))) return;
echo '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.css">';
echo '<script type="module" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.esm.js"></script>';
});

add_filter('the_content', function ($content) {
if (!is_singular(array('sfwd-lessons', 'sfwd-quiz', 'sfwd-topic'))) return $content;
return $content . <<<'HTML'
<feedback-modal project="<YOUR_PROJECT_ID>" embedded="true"></feedback-modal>
HTML;
});

Replace <YOUR_PROJECT_ID> with your project ID. The widget appears after each lesson, topic, or quiz.

Like and dislike buttons​

Inline Helpful and Not helpful rating buttons

Use this alternative in place of the floating-button code in functions.php. Define the functions only once:

// Add this once to your theme's functions.php for the chosen mode.
add_action('wp_head', function () {
if (!is_singular(array('sfwd-lessons', 'sfwd-quiz', 'sfwd-topic'))) return;
echo '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.css">';
echo '<script type="module" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pushfeedback/pushfeedback.esm.js"></script>';
});

add_filter('the_content', function ($content) {
if (!is_singular(array('sfwd-lessons', 'sfwd-quiz', 'sfwd-topic'))) return $content;
return $content . <<<'HTML'
<p>Was this helpful?</p>
<div class="pushfeedback-thumbs-row">
<feedback-button project="<YOUR_PROJECT_ID>" rating="1" button-position="default" modal-position="center" button-style="light" custom-font="true">
Helpful
</feedback-button>
<feedback-button project="<YOUR_PROJECT_ID>" rating="0" button-position="default" modal-position="center" button-style="light" custom-font="true">
Not helpful
</feedback-button>
</div>
HTML;
});

Replace <YOUR_PROJECT_ID> with your project ID. The widget appears after each lesson, topic, or quiz.

Next steps​

  • Customization: Adjust the widget's layout, styles, and text.
  • Integrations: Forward feedback to Slack, email, Jira, and more.