Question regarding ossn_unregister_menu_item

Dominik L Posted in General Discussion 5 months ago

How can I find out, what item i have to call?

for example, use ossnunregistermenu_item to disable messages icon on topbar?

How do I know how to find the correct code?

I already have this - but how to find out the code for messages or something similar?

ossnunregistermenu_item('photo', 'photo', 'wall/container/controls/home');

Replies
German Dominik L Replied 5 months ago

I try to extend my disablephotos component by a second component for disabling messages

That's the code from the disablephotos component and I want to adapt it for messages

<?php
/**
 * Open Source Social Network
 *
 * @package   Dominik Lieger
 * @author    Dominik Lieger
 * @license   GPL v2 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * @link      https://www.example.com
 */

function disablephoto_init() {
    if (ossn_isLoggedin() && !ossn_isAdminLoggedin()) {
        $user = ossn_loggedin_user();

        // Überprüfe, ob der Benutzer verifiziert ist
        if ((isset($user->is_verified_user) && !$user->is_verified_user) || !isset($user->is_verified_user)) {

            // Entferne die Foto-Upload-Menüs
            ossn_unregister_menu_item('photo', 'photo', 'wall/container/controls/home');
            ossn_unregister_menu_item('photo', 'photo', 'wall/container/controls/user');
            ossn_unregister_menu_item('photo', 'photo', 'wall/container/controls/group');

            // Callback für Foto-Upload-Aktion registrieren
            ossn_register_callback('action', 'load', function($c, $t, $p) {
                if (ossn_isLoggedin()) { // Überprüfe, ob der Benutzer eingeloggt ist
                    if ($p['action'] == 'ossn/photos/add') {
                        // Zeige die Nachricht an, dass der Foto-Upload nicht erlaubt ist
                        ossn_trigger_message(ossn_print('photos:upload:not:allowed'), 'error');
                        redirect(REF); // Weiterleitung zur vorherigen Seite
                    }
                }
            });
        }
    }
}

// Registriere die Hauptinitialisierungsfunktion
ossn_register_callback('ossn', 'init', 'disablephoto_init');
?>
Indonesian Arsalan Shah Replied 5 months ago

Its tricky to know unless menu are registered using register menu item function then it can be unregistered.

If you are asking about messages icon on top corner in topbar middle (friends/ messages /notifications) it is not registered using menu item its hardcoded.