11 Tweaks You Can Make In Asgaros Forums To Add More Functionality

Have you ever thought to increase user engagement on your blog?

As we all are aware of the fact that traditional forums and bulletin boards fuel discussions. You will be glad to know that there are some forum plugins that you can add to your WordPress site. And one of these plugins is Asgaros Forum, it is one of the popular and fast growing forum plugins for WordPress blogs.

asgaros forum - 11 Tweaks You Can Make In Asgaros Forums To Add More Functionality

Also see: Forum Topics From Previous Month October

Let’s see some of the tweaks/hacks you can make to this forum plugin in order to use it to the full potential.

#1. Subscribe To Own Topics Automatically

This tweak allows users automatically have a subscription for new topics created by them. Add the following code to theme’s functions.php file.

 function auto_subscribe($postID, $topicID) {
AsgarosForumNotifications::subscribeTopic();
}
add_action('asgarosforum_after_add_thread_submit', 'auto_subscribe', 10, 2);

#2. Add Captcha For Guest Postings

Your forum needs protection against spam bots and captcha will be needed to do it, especially when the guest posting functionality is enabled. There are lots of captcha plugins for WordPress you can use to add captcha for guest posting. At the moment two available hooks and filters for the Asgaros Forum plugin allows you to integrate captcha in your forum.

  • asgarosforum_editor_custom_content_bottom hook: Allows you to add custom functions to the bottom area of the editor.
  • asgarosforum_filter_insert_custom_validation filter: Can be used for custom checks to decide if a user is allowed to post new content.

You can use Really Simple CAPTCHA WordPress plugin to integrate into Asgaros Forum guest posting purpose. Just add the following code to your theme functions.php file.

function editor_custom_content_bottom() {
global $asgarosforum;
if (!is_user_logged_in() && $asgarosforum->options['allow_guest_postings']) {
$captcha_instance = new ReallySimpleCaptcha();
$captcha_word = $captcha_instance->generate_random_word();
$captcha_prefix = mt_rand();
$captcha_file = $captcha_instance->generate_image($captcha_prefix, $captcha_word);
$captcha_url = plugins_url().'/really-simple-captcha/tmp/'.$captcha_file;
echo '<div class="editor-row editor-row-captcha">';
echo '<span class="row-title">'.__('Captcha:', 'asgaros-forum').'</span>';
echo '<img src="'.$captcha_url.'" /><br />';
echo '<input type="text" name="captcha_value">';
echo '<input type="hidden" name="captcha_prefix" value="'.$captcha_prefix.'">';
echo '</div>';
}
}
add_action('asgarosforum_editor_custom_content_bottom', 'editor_custom_content_bottom');
function insert_custom_validation($status) {
global $asgarosforum;
if (!is_user_logged_in() && $asgarosforum->options['allow_guest_postings']) {
$captcha_instance = new ReallySimpleCaptcha();
$captcha_value = $_POST['captcha_value'];
$captcha_prefix = $_POST['captcha_prefix'];
$captcha_correct = $captcha_instance->check($captcha_prefix, $captcha_value);
$captcha_instance->remove($captcha_prefix);
if (!$captcha_correct) {
$asgarosforum->info = __('You must enter the correct captcha.', 'asgaros-forum');
return false;
}
}
return $status;
}
add_filter('asgarosforum_filter_insert_custom_validation', 'insert_custom_validation');

#3. Paste Images In Forum Posts

Asgaros Forum does not have the functionality to add/upload images right to the WordPress Media Library. But it is added to the list of future implementation.

You have to add images manually, upload the image to WordPress Media Library and copy-paste the url in Asgaros Forum. If you don’t want this way of doing things you can use Clipboard Images plugin which works right out of the box with Asgaros Forum to allow for pasting images directly in posts and uploading it to WordPress Media Library.

#4. Change Ordering Of Posts/Topics

This is possible with available filters in Asgaros Forum. You just have to add the following codes to your theme’s functions.php file if you want to use them.

Show newest posts first in topic

function custom_asgarosforum_filter_get_posts_order($order) {
$order = 'p1.id DESC';
return $order;
}
add_filter('asgarosforum_filter_get_posts_order', 'custom_asgarosforum_filter_get_posts_order');

Show newest topics first in forum

function custom_asgarosforum_filter_get_threads_order($order) {
$order = 't.id DESC';
return $order;
}
add_filter('asgarosforum_filter_get_threads_order', 'custom_asgarosforum_filter_get_threads_order');

Show oldest topics first in forum

function custom_asgarosforum_filter_get_threads_order($order) {
$order = 't.id ASC';
return $order;
}
add_filter('asgarosforum_filter_get_threads_order', 'custom_asgarosforum_filter_get_threads_order');

#5. Auto Post To Social Media Twitter

You can add this functionality to Asgaros Forum by adding code to the following hooks which allows you to execute certain actions after a topic or post is created.

  • asgarosforum_after_add_thread_submit
  • asgarosforum_after_add_post_submit

You can try to use them for implementing your automatic social media posts logic.

#6. Add Links To Your Profile

To add this feature you have to add code to the hook asgarosforum_after_post_author in your theme’s functions.php file.

add_action('asgarosforum_after_post_author', 'my_function_asgaros_cabinet', 10, 1);
function my_function_asgaros_cabinet($author_id) {
echo '......';
}

Example for the plugin WP-RECALL(not full excerpt):

add_action('asgarosforum_after_post_author', 'my_function_asgaros_cabinet', 30, 1);
function my_function_asgaros_cabinet($author_id) {
echo '<a href="'.get_author_posts_url($author_id).'" title="'.__('Profile','rcl-asgaros').'"><i style="color:'.$rcl_options['color_font_icon'].';" class="fa fa-user"></i></a>
<a href="'.rcl_format_url(get_author_posts_url($author_id),'chat').'" title="'.__('Private message','rcl-asgaros').'"><i style="color:'.$rcl_options['color_font_icon'].';" class="fa fa-comment"></i></a>
<a href="'.rcl_format_url(get_author_posts_url($author_id),'recall').'" title="'.__('Reviews','rcl-asgaros').'"><i style="color:'.$rcl_options['color_font_icon'].';" class="'.$rcl_options['icon_enable_recall'].'"></i></a>
<a href="'.rcl_format_url(get_author_posts_url($author_id),'groups').'" title="'.__('Groups','rcl-asgaros').'"><i style="color:'.$rcl_options['color_font_icon'].';" class="'.$rcl_options['icon_enable_groups'].'"></i></a>
<a href="'.rcl_format_url(get_author_posts_url($author_id),'publics').'" title="'.__('Publications','rcl-asgaros').'"><i style="color:'.$rcl_options['color_font_icon'].';" class="'.$rcl_options['icon_enable_publics'].'"></i></a></span>';
}

add link to your profile - 11 Tweaks You Can Make In Asgaros Forums To Add More Functionality

#7. Add Profile Link To Username

You do this by adding following code to your theme’s functions.php file. You need to replace the MY_CUSTOM_LINK with your profile link.

function my_filtered_post_username($username, $userID) {
return '<a href="MY_CUSTOM_LINK">'.$username.'</a>';
}
add_filter('asgarosforum_filter_post_username', 'my_filtered_post_username', 10, 2);

#8. Add Rank To Your Forum

Add the the rank to the forum:

1. administrator
2. moderator
3. contributor
4. author
5. editor

add ranks to forum - 11 Tweaks You Can Make In Asgaros Forums To Add More Functionality

To do this you just have to add this code to your theme’s functions.php file:

add_action('asgarosforum_after_post_author', 'my_asgarosforum_after_post_administration', 10, 2);
function getUserRoles($id) { 
$user = new WP_User((int)$id); 
return implode(' and ', $user->roles); 
}
function my_asgarosforum_after_post_administration($author_id, $author_posts) {
if (getUserRoles($author_id)=='administrator') {
echo '<div class="icon-status-admin">'.__('Admin','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>';
} else {
if (AsgarosForumPermissions::isModerator($author_id)) {
echo '<div class="icon-status-moderator">'.__('Moderator','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>';
} else {
if(getUserRoles($author_id)=='contributor') {
echo '<div class="icon-status-contributor">'.__('Contributor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>';
} else {
if(getUserRoles($author_id)=='author') {
echo '<div class="icon-status-author">'.__('Author','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>';
} else {
if(getUserRoles($author_id)=='editor') {
echo '<div class="icon-status-editor">'.__('Editor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>';};  
}  
}
}
}
}

Names can be changed. Add styles for the above code. Just add them to your theme’s style.css file.

/* rcl-af-integration */
#af-wrapper .icon-status-indent{
padding-left:5px;
}
#af-wrapper .icon-status-admin{
font-size: 13px;
font-weight:bold;
color: #F43D2A;
}
#af-wrapper .icon-status-moderator {
font-size: 13px;
font-weight:bold;
color: #469AC6;    
}
#af-wrapper .icon-status-contributor{
font-size: 13px;
font-style: normal;
color: #E3BB24;
}
#af-wrapper .icon-status-author{
font-size: 13px;
font-style: normal;
color: #099922;
}
#af-wrapper .icon-status-editor{
font-size: 13px;
font-style: normal;
color: #099922;
}

#9. Add Shortcode To Show Specific Content Only

Version 1.4 of the Asgaros Forum plugin allows you to extend the forum-shortcode with additional parameters. When this parameters are used, only specific content will be shown on a page.

Show a specific post:

[ forum post="POSTID"]

Show a specific topic:

[ forum topic="TOPICID"]

Show a specific forum/sub-forum:

[ forum forum="FORUMID"]
,/code>

Show a specific category:

[ forum category="CATEGORYID"]

Show multiple specific categories:

[ forum category="CATEGORYID1,CATEGORYID2"]

Dont forget to replace the IDs with the corresponding IDs of the elements which should be shown on your page.

#10. Add Elements To The Statistics Area

The asgarosforum_statistics_custom_element hook allows you to add custom elements to your statistics area.

You want to add a new element which shows you the number of forums? Simply add the following code to your themes functions.php file:

function my_custom_statistics_element() {
global $asgarosforum;
$data = $asgarosforum->db->get_var("SELECT COUNT(id) FROM {$asgarosforum->tables->forums}");
AsgarosForumStatistics::renderStatisticsElement('Forums', $data, 'dashicons-before dashicons-editor-justify');
}
add_action('asgarosforum_statistics_custom_element', 'my_custom_statistics_element');

#11. Add Who is Online

You can add this feature by installing WP-UserOnline WordPress plugin. Add the widget WP-UserOnline to your sidebar. You will see a shortcode inside the widget.

wp useronline widget shortcode - 11 Tweaks You Can Make In Asgaros Forums To Add More Functionality

Copy that shortcode and replace it in the following code.

add_action('asgarosforum_statistics_custom_element', 'my_function_footer', 10, 1);
function my_function_footer() {
echo '<div class="af-topic-icons">'.do_shortcode('[do_widget id=useronline-4]').'</div>';  
}

Conclusion

Hope you like all these tweaks, to know more you can visit Asgaros official forum. You can also post your new ideas, tips, so on and get replies over there.

wAAACwAAAAAAQABAEACAkQBADs= - 11 Tweaks You Can Make In Asgaros Forums To Add More Functionality

Founder of HinduGeek, WordPress Developer, Blogger, and Tech Enthusiast.

  • TheCryptoKeepers

    Great post and thanks for the codes, these really add some great functionality to the forum. I was wondering, how do you add the register link (wp-login.php?action=register) next to the existing login link? The current registration process is not very intuitive and I feel it’s keeping people from registering. Thanks again!

  • Stanley

    Hi there, thanks a lot !
    It works perfectly