• Resolved luke

    (@realstash)


    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)
  • Plugin Author Asgaros

    (@asgaros)

    Hello @realstash

    It depends on what you want to do. What do you want to modify/extend?

    Thread Starter luke

    (@realstash)

    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 8 years ago by luke.
    Yworld

    (@yworld)

    Hi @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 '......';
    
    }

    • This reply was modified 8 years ago by Yworld.
    Thread Starter luke

    (@realstash)

    Do I just copy and paste this code as it is or should i add something to the “…..” area?

    Plugin Author Asgaros

    (@asgaros)

    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

    (@realstash)

    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

    (@yworld)

    Hi @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 8 years ago by Yworld.
    Thread Starter luke

    (@realstash)

    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

    (@jgoldbloom)

    @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://www.ads-software.com/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

    jgoldbloom

    (@jgoldbloom)

    @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

    (@asgaros)

    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

    (@realstash)

    @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
    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

    (@jgoldbloom)

    @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. “https://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

    (@realstash)

    Thank you so much!!! It works perfectly!

    • This reply was modified 8 years ago by luke.
    jgoldbloom

    (@jgoldbloom)

    ??

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Using Hooks and Filters’ is closed to new replies.