How to Create User Reward Video Watching Wordpress Website

How to Create User Reward Video Watching WordPress Website | Complete Guide

Welcome to my blog. In this blog, I’ll be showing you “How to create a video-watching website” where users can earn money by just watching YouTube / Hosted videos. Currently, I have implemented YouTube videos from YouTube. The hero plugin used in this website is “Gamipress”. It is a plugin used to create a user reward system in different ways like commenting, visiting posts, etc. Learn more from Gamipress. So let’s learn to build such innovative websites in WordPress.

Preview

Wordpress website designing

Live Preview

Plugins Used

1. Elementor

Elementor is a user-friendly WordPress page builder that lets you design beautiful websites easily. With its drag-and-drop interface and lots of widgets and templates, you can create custom layouts without any coding

2. Pro Elements

Unlock all Premium features of Elementor

3. Elementor Header and Footer Builder

Elementor’s Header and Footer Builder lets users easily design custom, responsive headers and footers with its drag-and-drop editor. It offers dynamic elements like menus, logos, and social icons, and allows different designs for specific pages or devices without coding.

4. Gamipress

GamiPress is a powerful WordPress plugin that allows users to gamify their websites by awarding points, achievements, and ranks based on user activity. It integrates seamlessly with other plugins and offers extensive customization options, enabling site owners to engage users with badges, challenges, and leaderboards. GamiPress is easy to set up, making it ideal for boosting user interaction and loyalty.

5. Contact Forms 7

Contact Form 7 is a popular WordPress plugin that allows users to create and manage multiple contact forms easily

6. Ultimate Member

Ultimate Member is a versatile WordPress plugin that enables users to create customizable membership sites with ease. It allows the creation of user profiles, member directories, and user registration and login forms, offering various role-based permissions.

Code Snippets To Restrict Users Below 300 Points

// Custom validation filter for points withdrawal form
add_filter('wpcf7_validate_number*', 'custom_points_validation_filter', 20, 2);

function custom_points_validation_filter($result, $tag) {
    $tag = new WPCF7_FormTag($tag);

    if ('your-points' == $tag->name) {
        $points = intval($_POST['your-points']);
        $email = sanitize_email($_POST['your-email']);

        $user = get_user_by('email', $email);
        if ($user) {
            $user_id = $user->ID;
            $user_points = gamipress_get_user_points($user_id);

            if ($user_points < $points) {
                $result->invalidate($tag, 'Insufficient funds. You do not have enough points for this withdrawal.');
            } elseif ($points < 300) {
                $result->invalidate($tag, 'Minimum points required for withdrawal is 300.');
            }
        } else {
            $result->invalidate($tag, 'User not found.');
        }
    }

    return $result;
}

// Process the withdrawal request
add_action('wpcf7_before_send_mail', 'process_withdrawal_request');

function process_withdrawal_request($cf7) {
    $form_id = $cf7->id();

    // Check if it's the specific form you want to handle
    if ($form_id == 98) { // Use the correct form ID without leading zeros
        $submission = WPCF7_Submission::get_instance();
        if ($submission) {
            $data = $submission->get_posted_data();

            $name = sanitize_text_field($data['your-name']);
            $email = sanitize_email($data['your-email']);
            $points = intval($data['your-points']);

            $user = get_user_by('email', $email);
            if ($user) {
                $user_id = $user->ID;
                $user_points = gamipress_get_user_points($user_id);

                if ($user_points >= $points && $points >= 300) {
                    gamipress_deduct_points_from_user($user_id, $points);

                    // Optionally, send a confirmation email or message
                    wp_mail($email, 'Withdrawal Request Received', 'Your withdrawal request for ' . $points . ' points has been received.');

                    // Optionally, save the request to the database for admin review
                    // ...
                }
            }
        }
    }
}

Shortcodes for Contact Form 7

[text* your-name placeholder "Your Name"]
[email* your-email placeholder "Your Email"]
[number* your-points placeholder "Points to Withdraw

Watch Video Tutorial