AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

Filter by custom fields

Topic prefix

AI Assistant
Notifications
Clear all

[Solved] Exclude some forums from hide links for guests

3 Posts
2 Users
1 Reactions
1,027 Views
Posts: 10
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@alquimist08)
Active Member
Joined: 1 year ago
[#61833]

Hello!

First thanks for such incredible script is very well done.

Trying to adapt this script that works very well to hide visitors links

add_filter('wpforo_content_after', 'wpforo_hide_links_for_guests', 10);
function wpforo_hide_links_for_guests( $content ){
    if( WPF()->current_user_groupid === 4 ){
        $content = preg_replace('|<a[^>]+href=[^>]+>[^<>]+<\/a>|im', '<a href="#" rel="nofollow">[' . wpforo_phrase('Please login to see the link', false) . ']</a>', $content);
    }
   return $content;
}

From this code need to exclude two different forums that have important links for guests.

like this

else {
  WPF()->current_forumid_key === 3,6 ){
        $content = disable;
}

Trying with

WPF()->current_object['forumid'] variable

But it doesn't work with the forum number:

 I am lost don't know how to add the exclusions so that the code does not apply in just two different forums.

Can help me?

Thanks in advance


2 Replies
Sofy
Posts: 5774
 Sofy
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@sofy)
Support Team
Joined: 8 years ago

Hi,

The developers have provided the following code: 

add_filter('wpforo_content_after', function ( $content ){
    if( WPF()->current_user_groupid === 4 && ! in_array( WPF()->current_object['forumid'], [3,6] ) ){
       $content = preg_replace('#<a[^>]+href=[^>]+>[^<>]+</a>#im', '<a href="#" rel="nofollow">[' . wpforo_phrase('Please login to see the link', false) . ']</a>', $content);
    }
    return $content;
});

It should work fine. 


Posts: 10
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@alquimist08)
Active Member
Joined: 1 year ago

Works perfect..  thank you!! 👍 


Share: