If & else Conditional Statements

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
205
Points
53

Reputation:

Hello, dears,
Good day!

I have a javascript code and use it for disabling the coping functions on the forum.
How I can make it active for the visitors and members who have less than 200 threads or posts and disabled for others by using the if function?
Thank you.
 

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
3,520
Points
523

Reputation:

Hello, dears,
Good day!

I have a javascript code and use it for disabling the coping functions on the forum.
How I can make it active for the visitors and members who have less than 200 threads or posts and disabled for others by using the if function?
Thank you.
Wolf Knighttell us first how you have bind it to the xenforo installation and where.

And what has the content of this post to do with your subject?
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
205
Points
53

Reputation:

Hello,

I am using this code:

Code:
<xf:if is="!$xf.visitor.user_id">
    <script>
$(document).bind('copy', function(e){
alert ('message'); // Make alert for your visitors.
return false;
});
</script><xf:else />
</xf:if>

I want to activate it for all members who have less than 200 posts and all visitors.
and disable it for the others
 

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
3,520
Points
523

Reputation:

Hello,

I am using this code:

Code:
<xf:if is="!$xf.visitor.user_id">
    <script>
$(document).bind('copy', function(e){
alert ('message'); // Make alert for your visitors.
return false;
});
</script><xf:else />
</xf:if>

I want to activate it for all members who have less than 200 posts and all visitors.
and disable it for the others
Wolf KnightIn which template did you add it
 

Soft4Win

Developer
Staff member
Moderator
Collaborate
Registered
Joined
Apr 27, 2019
Messages
371
Points
103

Reputation:

You can try using this condition:

HTML:
<xf:if is="$xf.visitor.message_count|number <  200">
     <script>
        $(document).bind('copy', function(e){
             alert ('message'); // Make alert for your visitors.
             return false;
        });
   </script>
</xf:if>
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
205
Points
53

Reputation:

You can try using this condition:

HTML:
<xf:if is="$xf.visitor.message_count|number <  200">
     <script>
        $(document).bind('copy', function(e){
             alert ('message'); // Make alert for your visitors.
             return false;
        });
   </script>
</xf:if>
Soft4WinThank you for your response.
I tried it but it not working
 
View previous replies…

Soft4Win

Developer
Staff member
Moderator
Collaborate
Registered
Joined
Apr 27, 2019
Messages
371
Points
103

Reputation:

I have +16K posts and it is disabled for me.
Wolf KnightThat's strange, it should have worked properly. Once give a try to this:

HTML:
<xf:if is="$xf.visitor.message_count|number > 200">
     
    <xf:else />
     <script>
        $(document).bind('copy', function(e){
             alert ('message');
             return false;
        });
   </script>
</xf:if>
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
205
Points
53

Reputation:

That's strange, it should have worked properly. Once give a try to this:

HTML:
<xf:if is="$xf.visitor.message_count|number > 200">
     
    <xf:else />
     <script>
        $(document).bind('copy', function(e){
             alert ('message');
             return false;
        });
   </script>
</xf:if>
Soft4Winthe same issue, I can't copy anything.
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
205
Points
53

Reputation:

That's strange, it should have worked properly. Once give a try to this:

HTML:
<xf:if is="$xf.visitor.message_count|number > 200">
     
    <xf:else />
     <script>
        $(document).bind('copy', function(e){
             alert ('message');
             return false;
        });
   </script>
</xf:if>
Soft4WinIt's disabled for all
 

Soft4Win

Developer
Staff member
Moderator
Collaborate
Registered
Joined
Apr 27, 2019
Messages
371
Points
103

Reputation:

It's disabled for all
Wolf KnightI tried this one at my site, In which my main account had 157 posts, and a test account had 0 posts. So when copying through main account it worked fine, and when copying through test account it gave that alert.

HTML:
<xf:if is="$xf.visitor.message_count|number < 150">
     <script>
        $(document).bind('copy', function(e){
             alert ('You are not allowed to copy content');
             return false;
        });
   </script>
</xf:if>
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
205
Points
53

Reputation:

I tried this one at my site, In which my main account had 157 posts, and a test account had 0 posts. So when copying through main account it worked fine, and when copying through test account it gave that alert.

HTML:
<xf:if is="$xf.visitor.message_count|number < 150">
     <script>
        $(document).bind('copy', function(e){
             alert ('You are not allowed to copy content');
             return false;
        });
   </script>
</xf:if>
Soft4Winso shall I add it to PAGE_CONTAINER or another one?
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
205
Points
53

Reputation:

I added it to Page_container, just above the closing body tag </body>
Soft4WinIt's working now with 150 only, with 200 not working.
is message_count mean threads only or total or what exactly?
I appreciated your continued assistance.
 

Soft4Win

Developer
Staff member
Moderator
Collaborate
Registered
Joined
Apr 27, 2019
Messages
371
Points
103

Reputation:

It's working now with 150 only, with 200 not working.
is message_count mean threads only or total or what exactly?
I appreciated your continued assistance.
Wolf Knightmessage_count includes the count of threads aswell as posts. Internally threads are also kind of posts , just their position in first in a thread.
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
205
Points
53

Reputation:

Yaa don't know why it have that weird behavior, I did faced such issues earlier aswell, not sure if i fixed it at that time, can't remember atm.
Soft4WinHello dear,
Just for your kind information, I removed this code and back to using the general one that I used before because the last one you shared (150) is disabling the coping for other groups as well, the issue I thinks is regards what it counts posts with $xf. visitor.message_count|number < 150? or it's not comfortable with Java!
It's strange!
 
Top