Title: Using Hooks and Filters
Last modified: February 26, 2017

---

# Using Hooks and Filters

 *  Resolved [luke](https://wordpress.org/support/users/realstash/)
 * (@realstash)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/)
 * Hi, thanks for the amazing forum plugin!
 * I realized that most of the customization options are not in the actual plugin
   settings but within the hooks and filters. Can you please tell me how I can use
   these and implement them into my website? Where should I add them? Can another
   plugin do all the work or do I have to go into the files themselves?
 * Thanks for your help in advance!

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/using-hooks-and-filters/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/using-hooks-and-filters/page/2/?output_format=md)

 *  Plugin Author [Asgaros](https://wordpress.org/support/users/asgaros/)
 * (@asgaros)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8850469)
 * Hello [@realstash](https://wordpress.org/support/users/realstash/)
 * It depends on what you want to do. What do you want to modify/extend?
 *  Thread Starter [luke](https://wordpress.org/support/users/realstash/)
 * (@realstash)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8850636)
 * Thank you for responding so fast!
    I would love to add links to the users profile
   directly from the forum. At the moment that is pretty much all. Can you tell 
   me how to accomplish this?
 * Thanks!
    -  This reply was modified 9 years, 5 months ago by [luke](https://wordpress.org/support/users/realstash/).
 *  [Yworld](https://wordpress.org/support/users/yworld/)
 * (@yworld)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8850653)
 * Hi [@realstash](https://wordpress.org/support/users/realstash/)
    To do this you
   just have to add this code to your themes functions.php file:
 *     ```
       add_action('asgarosforum_after_post_author', 'my_function_asgaros_cabinet', 10, 1);
       function my_function_asgaros_cabinet($author_id) {
   
       	echo '......';
   
       }
       ```
   
 * ![](https://i0.wp.com/image.prntscr.com/image/0fbace61ca5644d1830c8a3a5ae5a2ae.
   png)
    -  This reply was modified 9 years, 5 months ago by [Yworld](https://wordpress.org/support/users/yworld/).
 *  Thread Starter [luke](https://wordpress.org/support/users/realstash/)
 * (@realstash)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8854955)
 * Do I just copy and paste this code as it is or should i add something to the “…..”
   area?
 *  Plugin Author [Asgaros](https://wordpress.org/support/users/asgaros/)
 * (@asgaros)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8854972)
 * You have to add your PHP logic/code there which contains the stuff you want to
   display/modify/etc. This logic/code depends on the profile-plugin and its API
   which you are using.
 *  Thread Starter [luke](https://wordpress.org/support/users/realstash/)
 * (@realstash)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8854990)
 * Oh ok, I am using the Ultimate Member plugin; can you inform me as to what I 
   should place there since I am using that plugin?
 *  [Yworld](https://wordpress.org/support/users/yworld/)
 * (@yworld)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8855605)
 * Hi [@realstash](https://wordpress.org/support/users/realstash/) Check the:
 *     ```
       function cdsnForumAuthorInfo() {
   
         um_fetch_user( get_current_user_id() );
           echo "<br /><div>Gender:".um_user('gender')."</div>"; 
           echo "<div>Country:".um_user('country')."</div>";
           echo "<div>Bio:".um_user('description')."</div>";  
   
           }
       add_action('asgarosforum_after_post_author', 'cdsnForumAuthorInfo');
       ```
   
    -  This reply was modified 9 years, 5 months ago by [Yworld](https://wordpress.org/support/users/yworld/).
 *  Thread Starter [luke](https://wordpress.org/support/users/realstash/)
 * (@realstash)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8858974)
 * The code you provided works perfectly but I only want to link the user’s name
   to their profile, not display their information underneath the name. Can you 
   assist me in linking the actual name to the user profile please? In example, 
   if the user’s name is Joe, I’d like to be able to click the actual name and go
   to Joe’s profile.
 *  [jgoldbloom](https://wordpress.org/support/users/jgoldbloom/)
 * (@jgoldbloom)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8861454)
 * [@luke](https://wordpress.org/support/users/luke/)
 * Hey, I happen to use Ultimate Member and added below to functions.php to exploit
   the massively cool and useful Asgaros hooks/filters. Modify then style accordingly,
   but that’s production code using UM functions to add post author details based
   on UM meta in the profile form plus login/register link at the top of Asgaros
   based on UM forms as well:
 *     ```
       /* 
   
       BEGIN: CDSN PLUGIN HOOKS OR THEME HOOKS - JG 2/10/2017 
   
       Asgaros plugin hooks to add forum disclaimer detail (html) in various areas...
       See https://wordpress.org/plugins/asgaros-forum/faq/
   
       */
   
       function cdsnForumAuthorInfo($author_id) {
   
       	if ($author_id) {
   
       		um_fetch_user($author_id);
   
       		$content="<div class='cdsnProfileWrapper'>";
   
       		$data=um_user('type');
       		$typeHere=$data[0];
   
       		$content.="<div class='cdsnProfileTypeHere'>$typeHere</div>";
   
       		$user_info = get_userdata($author_id);
       		foreach ($user_info->roles as $role) {
       			$role_arr[]=ucfirst($role);
       		}
               $roles=implode(', ', $role_arr);
   
               $content.="<div class='cdsnProfileRoles'>($roles)</div>";
   
       		$content.="<div class='cdsnProfileGenderFlagWrapper'>";
   
       		    $content.="<span class='cdsnProfileGender'>".cdsnGetGender(um_user('gender'))."</span>"; 
   
       		    $content.="<span class='cdsnProfileFlag'>".cdsnGetCountryFlag(um_user('country'))."</span>";
   
       	    $content.="</div>";
   
       	    $cancerType=um_user('cancer');
   
       	    if ($cancerType!=='N/A' && !empty($cancerType)) {
   
       	    	$content.="<div class='cdsnProfileCancer'>$cancerType</div>";
   
       	    	$diagnosed=um_user('diagnosed');
   
       	    	if ($diagnosed!=='N/A' && !empty($diagnosed))  { 	
   
       				$content.="<div class='cdsnProfileDiagnosed'>Diagnosed $diagnosed</div>";
   
       			}
   
       	    }
   
       	    $content.="
       	    <a href='#cdsnProfileCancerBio' title='Cancer Bio...'>
       	    <span class='cdsnProfileCancerBioButton'>
       	    <img src='/cdsn-images/profiles/cancerbio.gif' alt='Cancer Bio...' />&nbsp;Cancer Bio</span>
       	    </a>";
   
           $content.="</div>"; 
   
           $content.="<div class='cdsnProfileCancerBio'>".um_user('cancerbio')."</div>";
   
           echo $content;
   
           }
   
        }
   
       function cdsnForumLoginRequired($message) {
       	return "<p><br />&bull; You must <a href='/login' title='Login...'>log in</a> or <a href='/register' title='Register as a new member...'>register</a> to contribute to our forum...<br /></p>";
       }
   
       function cdsnForumLoginErrorMessage($message) {
       	return '';
       }
   
       add_filter('asgarosforum_filter_login_message', 'cdsnForumLoginRequired');
       add_filter('asgarosforum_filter_error_message_require_login', 'cdsnForumLoginErrorMessage');
       add_action('asgarosforum_after_post_author', 'cdsnForumAuthorInfo',10,1);
   
       /* END: ALL CUSTOM CDSN HOOKS - JG */
       ```
   
 * Looks like this:
 * ![asgaros author info](https://i0.wp.com/www.cancerdefiance.net/cdsn-images/screenshots/
   asgaros-author-data.png)
 *  [jgoldbloom](https://wordpress.org/support/users/jgoldbloom/)
 * (@jgoldbloom)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8861489)
 * [@luke](https://wordpress.org/support/users/luke/)
 * As to UM profile link from the Asgaros generated author name that would require
   either the plugin author to add an option, or you could use jQuery to wrap an
   anchor around the selector as a not so great workaround.
 * But you could much more easily use the method noted above and add into your hook
   a nicely style a text link/button/image (whatever) that points to the slug setup
   in UM for your profile page. I posted that method to show the power of the hook
   system but this reply should get you going.
 *  Plugin Author [Asgaros](https://wordpress.org/support/users/asgaros/)
 * (@asgaros)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8861891)
 * Hi everyone
 * > As to UM profile link from the Asgaros generated author name that would require
   > either the plugin author to add an option
 * There is already a filter for the username:
    – asgarosforum_filter_post_username
 * Inside it you can work with the username and the user-ID.
 * Here is an example to put a link around it:
 *     ```
       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);
       ```
   
 * Regards,
    Thomas
 *  Thread Starter [luke](https://wordpress.org/support/users/realstash/)
 * (@realstash)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8863193)
 * [@jgoldbloom](https://wordpress.org/support/users/jgoldbloom/)
 * Thank you! This is a really cool feature to add, maybe this can be encoded into
   the admin panel for the plugin so that we can choose what we would like to display
   on the front end.
 * Also, [@asgaros](https://wordpress.org/support/users/asgaros/)
    Would the filter
   for the username that you just provided work for the function I am asking for?
   Is there any way for me to use this with Ultimate Member?
 *  [jgoldbloom](https://wordpress.org/support/users/jgoldbloom/)
 * (@jgoldbloom)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8863363)
 * [@luke](https://wordpress.org/support/users/luke/)
 * In UM create a profile form, then create a new page in WP with the UM shortcode
   to render the profile form and assign in your page a permalink with the path 
   i.e. “[http://yourdomain.com/profile&#8221](http://yourdomain.com/profile&#8221);.
   After that go to UM settings > setup > user page and assign your profile page
   there so UM is aware. Finally, in function.php in your theme or child theme use
   the filter (as the plugin author reminded me it exists already, my bad) and set
   the href in the Asgaros filter use the the permalink.
 *  Thread Starter [luke](https://wordpress.org/support/users/realstash/)
 * (@realstash)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8863992)
 * Thank you so much!!! It works perfectly!
    -  This reply was modified 9 years, 5 months ago by [luke](https://wordpress.org/support/users/realstash/).
 *  [jgoldbloom](https://wordpress.org/support/users/jgoldbloom/)
 * (@jgoldbloom)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/#post-8865245)
 * 🙂

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/using-hooks-and-filters/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/using-hooks-and-filters/page/2/?output_format=md)

The topic ‘Using Hooks and Filters’ is closed to new replies.

 * ![](https://ps.w.org/asgaros-forum/assets/icon-128x128.png?rev=1546717)
 * [Asgaros Forum](https://wordpress.org/plugins/asgaros-forum/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/asgaros-forum/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/asgaros-forum/)
 * [Active Topics](https://wordpress.org/support/plugin/asgaros-forum/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/asgaros-forum/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/asgaros-forum/reviews/)

 * 16 replies
 * 4 participants
 * Last reply from: [luke](https://wordpress.org/support/users/realstash/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/using-hooks-and-filters/page/2/#post-8866818)
 * Status: resolved