How to hide a button for the owner?

Please I used this code, check see, is it valid and if not, what would you suggest I do.

On this page I display requests made by users, and experts open and respond to their requests, it wouldn’t be professional if the user opens it and also is allowed to respond to his ownself.

This is my code:

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

$w.onReady( () => {
if (wixUsers.currentUser.owner) {
$w(‘#propose’).show();

}
else {
$w(‘#propose’).hide();
}
} );

Hello

I recommend you check out the documentation for Wix Users here : https://www.wix.com/code/reference/wix-users.User.html#role

There are three roles in wix:
Admin
Member
Visitor

We check to see if the current user is the admin and we hide and show accordingly.

import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady( () => {
if(wixUsers.currentUser.role === 'Admin') {  
$w('#propose').show();
} else {
$w('#propose').hide();
}

Goodluck!
Majd

1 Like