Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
Disable mycred plugin on a specific forum / group
Avatar
Yehonal
Member
sp_UserOfflineSmall Offline
Dec 29, 2015 - 4:38 am

Hello SP community

I looking for a way to disable mycred plugin ( but also other plugins if is it possible ) on specific forums & groups.

Ex: i've mycred hook plugin that gives points for opened topics, likes and dislikes. But i've also an off-topic forum full of "spam" and i should avoid that my users can gain any kind of points in that section..

Is there a way to disable mycred on that forums, or just some of its functions ( such as points on opened topic etc ) ?

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Dec 29, 2015 - 5:53 am

You can certainly optionally display any component on any of the main forum views but it does mean making edits to the templates of course - which would then require a custom theme to avoid losing those edits on future updates. So that would be the first thing to do. If only one template is involved then a child theme would be the best way to go. There are instructions for both in our codex 'themes' section.

Then it is a matter of locating the display function in the appropriate template and wrapping some conditional statements around it - like 'if' statements - to determine if the component should be displayed or not. As I do not know how well your coding in php is then it is hard to target the right level of explanation - but it is a simple matter.

If you go to the forum admin > toolbox > data inspector then you can turn on displays of the underlying data object for each view and each segment of the view. This data is available to the template through global standard objects.

Now - of course - the above applies to any plugin code that has a display component which itself triggers some sort of activity (like post rating or post thanks for example). The MyCred extension is a different matter as that is triggered by the post save action. The only way to to prevent that is to remove the hooks (standard WordPress hook behaviour)  under conditional circumstances which should be able to be achieved in the spFunctions.php template. The appropriate hooks are, if I recall correctly, actually defined in the WP myCred plugin - I would need to download it again to ascertain the actual hook names being used.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Yehonal
Member
sp_UserOfflineSmall Offline
Dec 29, 2015 - 6:08 am

thanks for fast reply 🙂

i don't need to disable thanks/like display since they can continue to use it but they shouldn't assign Points.

So i think i need just a "filter" that avoid mycred points addition/subtraction on specific forums.

The MyCred plugin is quite simple ... and i din't understand where options are stored . 

I've also found sp_mycred_process_points and sp_mycred_get_settings , functions inside it but they seems not used ( deprecated maybe? )

 

So..A simple ( ugly ) workaround would be to "deregister" hook_simplepress_extensions totally when i'm on specific forums. Could you help me to find the best way to do it?

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Dec 29, 2015 - 7:06 am

I think you can do myCred (and I have not tried as it would need some time to set things up) by removing the myCred filter that is added by:

add_filter( 'mycred_setup_hooks', 'SimplePress_myCRED_Hook' );

Look at the WP remove_filter() function for this.

Assuming then you want this on the forum view (to stop a new topic action) and the topic view (to stop a new post to a topic) then the two globals involved there are:

$spThisForum and $spThisTopic

both of which have a 'forum_id' property.

So you need to test (a) if that global is defined and (b) if it is the correct forum. There is also a global array (NOT object) called 

$spVars

which has an element named 'pageview' which will tell you whether the current page is the group, forum or topic view. Using a combination of these will stop notices and warnings being generated of course.

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17362
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625