Free Birthday Box Plugin for Community Users

MakeMyTheme Admin
Admin
Alăturat: 2024-12-27 09:02:43
2025-01-11 20:34:12

 

LICENSE CERTIFICATE & INSTALLATION GUIDELINES
Plugin Name: Friends Birthday Box (Version 1.1)
Thank you for purchasing the Friends Birthday Box Plugin V1.1. This plugin does not require any license activation and is ready to use upon installation. Follow the instructions below to set up the plugin and enhance your community engagement.
For assistance during installation or customization, feel free to reach out to help@makemytheme.com.

Installation Instructions
1. Prepare Your Theme Directory
Navigate to your active theme's directory.
Example: default/templates/.
Create a new folder named widgets (if it doesn't already exist).
Final path: default/templates/widgets/.

2. Upload Plugin Files
Place the file fbirthday-wish.tpl inside the widgets folder.
Place the file customstyle.css inside the css folder of your active theme.
Optional Shortcut:
If you are using the default Sngine theme, you can upload the entire content folder provided with the plugin. This will place all files in the correct locations automatically.

3. Add CSS Reference
Open the _head.tpl file located in your theme's templates folder.
Locate the following line of CSS:
html
Copy code
<link rel="stylesheet" type='text/css' href="{$system['system_url']}/content/themes/{$system['theme']}/css/style.rtl.min.css">

Add the following line immediately after:
html
Copy code
<!-- #Dudu changes -->
<link rel="stylesheet" type='text/css' href="{$system['system_url']}/content/themes/{$system['theme']}/css/customstyle.css">
<!-- #Dudu changes -->


4. Insert Widget in Sidebar
Open _sidebar.tpl or index.newsfeed.tpl in the templates folder.
Find the desired location for the widget (e.g., after the "Pro Members" section).
Insert the following code where you want the Birthday Box widget to appear:
smarty
Copy code
{include file='./widgets/fbirthday-wish.tpl'}


5. Add Backend Functionality
Open the file includes/class-user.php.
Add the following function before the last closing bracket (}):
php
Copy code

 

  public function get_friends_birthday($user_id = null)
  {
      global $db, $user, $system;
      $friend_birthday = [];
      $current_month = date('m');
      $current_day = date('d');


       if (!$this->_logged_in) {
           return $friend_birthday;
       }
       $query = "
       SELECT users.user_id, users.user_name, users.user_firstname, users.user_lastname, users.user_gender, users.user_picture, users.user_subscribed, users.user_verified, users.user_birthdate
       FROM users
       INNER JOIN friends ON (
           (friends.user_one_id = users.user_id AND friends.user_two_id = $user_id AND friends.status = 1)
           OR
           (friends.user_two_id = users.user_id AND friends.user_one_id = $user_id AND friends.status = 1)
       )
       WHERE MONTH(users.user_birthdate) = '$current_month' AND DAY(users.user_birthdate) = '$current_day'
       ORDER BY RAND()
       LIMIT 1";


     $get_friend_birthday = $db->query($query);


     if (!$get_friend_birthday) {
         echo "Database Error: " . $db->error;
         return $friend_birthday;
     }


     if ($get_friend_birthday->num_rows > 0) {
         while ($birthday = $get_friend_birthday->fetch_assoc()) {
             $birthday['user_picture'] = get_picture($birthday['user_picture'], $birthday['user_gender']);
             $friend_birthday[] = $birthday;
         }
     }

 

     return $friend_birthday;
 }

 

6. Update the Homepage Logic
Open the index.php file in your root directory.
Add the following code before the page footer section (// page footer):
php
Copy code

 

  // 01. Friends Birthday Plugin
$friends_birthday = $user->get_friends_birthday($user->_data['user_id']);
$smarty->assign('friends_birthday', $friends_birthday);


$current_date_birthday = (!empty($friends_birthday)) ? $friends_birthday[0] : null;


if ($current_date_birthday) {
    $smarty->assign('current_date_birthday', $current_date_birthday);


    // Pre-calculate birth day and month for the Smarty template
    $birth_day = date('d', strtotime($current_date_birthday['user_birthdate']));
    $birth_month = date('F', strtotime($current_date_birthday['user_birthdate']));


    $smarty->assign('birth_day', $birth_day);
    $smarty->assign('birth_month', $birth_month);
}

 


7. Add Background Images
Use a background image or GIF to style the widget.
Place these assets in your theme's images folder or directly upload the provided content folder to ensure automatic placement.

Features Summary
Effortless Integration: Add the Birthday Box anywhere on your platform.
Customizable Styling: Easily edit widget styles using the provided CSS.
Engaging User Interaction: Encourage users to send birthday wishes and increase activity.
Optimized Backend Logic: Fetch friends’ birthdays dynamically from the database.

Troubleshooting
Widget Not Showing
Ensure the fbirthday-wish.tpl file is correctly placed in the widgets folder.
Confirm you added the {include} code in _sidebar.tpl or index.newsfeed.tpl.
CSS Not Loading
Check if the customstyle.css file is uploaded to the css folder.
Verify that the CSS reference is added to _head.tpl.
Database Errors
Ensure the get_friends_birthday function is added correctly to class-user.php.
Confirm the database query is properly fetching the required data.

Support
For installation or customization assistance, please contact:
Email: help@makemytheme.com
Website: https://makemytheme.com
For queries about the license or this document, reach out to the Help Team via the website.

Thank You!
We appreciate your investment in the Friends Birthday Box Plugin and hope it helps you build a thriving online community. Check out more customizations and plugins at makemytheme.com.

Link to Download the Plugin