delete notifications
-
if buddypress clear notifications plugin does not working for u , this is a solution how to do it ,we will add a button”clear all notifications” in the notifications nav menu , first we will edit a php script called test.php wich contain this code
<?php function clear_all_notifications() { require_once( 'wp-load.php' ); //put correct absolute path for this file $id = get_current_user_id(); // on se connecte Ă MySQL $db = mysql_connect('localhost', 'user', 'password'); //replace user and password mysql_select_db('name of database',$db); $requete = 'SELECT * FROM prefix_bp_notifications WHERE user_id='. $id ; // verify the name of table here prefix_bp_notifications can be wp_bp_notifications $sql = 'DELETE FROM prefix_bp_notifications WHERE user_id ='. $id ; // verify the name of table here prefix_bp_notifications can be wp_bp_notifications $reponse = mysql_query($requete); $resultat = mysql_num_rows($reponse); if($resultat > 0){ $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); mysql_close(); echo "Notifications supprimees"; } else { echo $resultat ; echo "pas de notifications"; mysql_close(); } } clear_all_notifications(); ?> copy this script into ur document root where u have installed ur wordpress then add this code to wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/single/notifications.php under <?php bp_get_options_nav(); ?> line 13 <li id="notifications-my-notifications-personal-li" class="current selected"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script type = "text/javascript"> function myAjax () { $.ajax( { type : 'POST', data : { }, url : 'ur website adresse/test.php', // <=== CALL THE PHP FUNCTION HERE. success: function ( data ) { return 1; // <=== VALUE RETURNED FROM FUNCTION. }, error: function ( ) { return 1; } }); } //function execute_del(){ //myAjax(); //window.location.reload(); //} </script> <button onclick="myAjax();window.location.reload();">delete all notifications</button> <!-- BUTTON CALL PHP FUNCTION --> </li>
that’s all đ
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.