PDA

View Full Version : Zoins Anonymous Posting - Help with PHP Edit. [Completed]


akz645
08-02-2015, 12:28 AM
Hello,

For anyone who wants to add/enable a check box for post anonymously at the Quick Reply box, Here's how:

Tested and working with vBulletin 4.2.2 Patch Level 1.

It just requires one template change and 1 plugin to be created. The plugin is what allows the if statement to work on the showthread page (where the quick reply is).

1. Go to your admincp
2. Navigate to Plugins & Products, and then into Add New Plugin
3. Enter the following:

Product: Zoints Anonymous Posting
Hook Location: showthread_start
Title: Enable Anonymous Posting (Quick Reply)
Execution Order: 5
Plugin PHP Code:



$show['anonymous'] = false;
if ($vbulletin->options['zointsanony_enabled'] AND $vbulletin->options['zointsanony_userid'])
{
$anonyforums = explode(',',$vbulletin->options['zointsanony_forums']);
foreach ($anonyforums AS $fid)
{
if ($fid == $forumid)
{
$show['anonymous'] = true;
}
}
}



4. Set plugin to Active.
5. Save
6. Go to your Style Manager and edit the following template SHOWTHREAD.

Find:



<li><label for="cb_openclose">
<input type="checkbox" name="openclose" id="cb_openclose" value="1" tabindex="1" />
<vb:if condition="$show['closethread']">{vb:rawphrase close_this_thread}<vb:else />{vb:rawphrase reopen_this_thread}</vb:if>
</label></li>




Below, Add:




<vb:if condition="$show['anonymous']"><div><input type="checkbox" id="cb_anonymous" class="bginput" name="anonymous" value="1" checked="checked" /> {vb:rawphrase zointsanony_anonymous_post}</div></vb:if>




7. Save

Now go to a thread in a forum where you have Anonymous posting enabled, and you should see the Quick Reply Anonymous option at Quick Reply box.

Thanks to vespillo and New Joe for the help. I collected the information above from their replies.

Basically. that solution still has the following issues:
- Users who can't open/close a thread, can't view the quick reply checkbox to post anonymously.
- The box is checked by default, I want it unchecked.

How do I do this?

MarkFL
08-02-2015, 01:30 AM
What you want to do is create a new plugin as follows:

Product: Zoints Anonymous Posting

Hook Location: showthread_complete

Title: Enable Anonymous Posting on Quick Reply

Execution Order: 5

Plugin PHP Code:

$show['anonymous'] = false;
if ($vbulletin->options['zointsanony_enabled'] AND $vbulletin->options['zointsanony_userid'])
{
$anonyforums = explode(',',$vbulletin->options['zointsanony_forums']);
foreach ($anonyforums AS $fid)
{
if ($fid == $forumid)
{
$show['anonymous'] = true;
}
}
}

Next, in your "SHOWTHREAD" template, locate the code:

<vb:if condition="$show['openclose']">
<div class="openclose">
<ul class="checkradio">
<li><label for="cb_openclose">
<input type="checkbox" name="openclose" id="cb_openclose" value="1" tabindex="1" />
<vb:if condition="$show['closethread']">{vb:rawphrase close_this_thread}<vb:else />{vb:rawphrase reopen_this_thread}</vb:if>
</label></li>
</ul>
</div>
</vb:if>

And below this, add:

<vb:if condition="$show['anonymous']">
<div class="openclose">
<ul class="checkradio">
<li>
<input type="checkbox" id="cb_anonymous" class="bginput" name="anonymous" value="1" /> {vb:rawphrase zointsanony_anonymous_post}
</li>
</ul>
</div>
</vb:if>

--------------- Added 1438487758 at 1438487758 ---------------

Nevermind I fixed the issue myself :D

@Mods
Delete this thread please.

Please, in the future if you post a question and then find a solution, rather than gutting your original post (devaluing the thread) and asking for the thread to be deleted, go ahead and post your solution for the benefit of the community. :)

akz645
08-02-2015, 03:21 AM
Ah, thanks for posting that. I thought I edited it out before anybody got a chance to see it (hence avoid wasting their time).
I posted the solution onto the thread itself, as that's more relevant than posting it here.

Your solution is actually slightly different and better (edited into the solution post now (https://vborg.vbsupport.ru/showpost.php?p=2551699&postcount=195)). I learnt how to position the check box better (no idea what </ul> did) :)

Thanks anyway though :)
*Edited my original post back (more or less), since you took the time to post an answer*

MarkFL
08-02-2015, 03:46 AM
If you wish for this to work for certain usergroups only, then change the template conditional to read:

<vb:if condition="$show['anonymous'] and is_member_of($bbuserinfo, X,Y,...)">

where X,Y... is the comma-delimited list of usergroups you want to allow. :)

akz645
08-02-2015, 04:04 AM
If you wish for this to work for certain usergroups only, then change the template conditional to read:

<vb:if condition="$show['anonymous'] and is_member_of($bbuserinfo, X,Y,...)">

where X,Y... is the comma-delimited list of usergroups you want to allow. :)
https://vborg.vbsupport.ru/showpost.php?p=2551920&postcount=196
Cheers. Added to my next post.

Elixar
08-02-2015, 04:00 PM
What would be really awesome is to allow who can see the username of the actual poster in the postbit. :D

Elixar
12-27-2015, 05:03 PM
What would be really awesome is to allow who can see the username of the actual poster in the postbit. :D

Bump. :D

akz645
12-31-2015, 08:27 PM
What would be really awesome is to allow who can see the username of the actual poster in the postbit. :D
You should be posting that request on the actual modification thread (https://vborg.vbsupport.ru/showthread.php?t=177694).