Please or Register to create posts and topics.

Add profile shortcode

Hi Thomas

I suggest this option:

<?php

if (!defined('ABSPATH')) exit;

// статистика asgaros forum
function AsgarosForumProfile($user_id, $type, $title){
    if (!class_exists('AsgarosForumStatistics')) return false; // If asgaros is not enabled
        global $wpdb, $otfm_asf_cnt;
        if(!$otfm_asf_cnt){ // Once filling the global variable - subsequent options for requesting functions are not sent to the database
            $otfm_asf_cnt = $wpdb->get_results(""
                    . "SELECT "
                    . "COUNT(parent_id) as total_posts, "
                    . "count(DISTINCT parent_id) AS forum_start "
                    . "FROM ".$wpdb->prefix."forum_posts "
                    . "WHERE author_id = ".$user_id." "
                    . "GROUP BY author_id "
                    . "",ARRAY_A);
            if(!$otfm_asf_cnt) $otfm_asf_cnt[0] = array('none'); // if the query did not return anything - write 'none' to subsequent requests in the idle not to drive
        }
        if($type == 'asf_issues'){ // created themes
            $cnt = $otfm_asf_cnt[0]['forum_start'];
        }
        if($type == 'asf_reply'){ // the total number of messages
            $cnt = $otfm_asf_cnt[0]['total_posts'];
        }
        if(!$cnt) return false;
        $out = '<div class="otfm_asgrs_blk otfm_asgrs_'.$type.'">';
            $out .= '<span class="otfm_asgrs_title">'.$title.'</span>';
            $out .= '<span class="otfm_asgrs_cnt">'.$cnt.'</span>';
        $out .= '</div>';
        return $out;
    
}
function AsgarosForumProfileShortcodes($user_ID){
  global $user_ID;
  
  if(!is_user_logged_in()) return false;
  
  $content .= '<div>'.get_avatar($user_ID, 100).'</div>';
  $groupsOfUser = AsgarosForumUserGroups::getUserGroupsForUser($author_id);
  if (($groupsOfUser[0]->name) !== NULL)
  {
    $content .= '<div class="">'.($groupsOfUser[0]->name).'</div>';
}
  $content .= AsgarosForumProfile($user_ID, $type='asf_issues', $title='Created topics: ');
    $content .= AsgarosForumProfile($user_ID, $type='asf_reply', $title='Messages created: ');
    
    return $content;
}
add_shortcode( 'forum_profile', 'AsgarosForumProfileShortcodes' );

Display messages, themes, group, avatar

Helped make Otshelnik-Fm

I hope it will come in handy 🙂

 

Uploaded files:
  • Screenshot_2.jpg

Hello Yworld,

user profiles are already on my todo-list and I plan to add them with one of the next bigger updates – maybe 1.6 or 1.7. Here is the relevant GitHub ticket:

https://github.com/Asgaros/asgaros-forum/issues/131

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Excellent!

With the ability to integrate into existing plugins profiles? It would be perfect 🙂

 

 

Quote from Asgaros on May 27, 2017, 9:02 pm

Hello Yworld,

user profiles are already on my todo-list and I plan to add them with one of the next bigger updates – maybe 1.6 or 1.7. Here is the relevant GitHub ticket:

https://github.com/Asgaros/asgaros-forum/issues/131

 

Quote from Yworld on May 27, 2017, 9:08 pm

Excellent!

With the ability to integrate into existing plugins profiles? It would be perfect 🙂

 

It would be perfect indeed. 🙂