Please or Register to create posts and topics.

How can i desactive or delete Forum menu?

PreviousPage 2 of 2
Quote from Asgaros on May 21, 2019, 12:31 pm

Hello @adnan

For translating-purposes I suggest you to use the following extension:

https://wordpress.org/plugins/loco-translate/

For getting all posts of a user I suggest you to use the following function:

global $asgarosforum;
$posts = $asgarosforum->profile->get_post_history_by_user($user_id, $limit = false);
  1. global $asgarosforum;
  2. $posts = $asgarosforum>profile>get_post_history_by_user($user_id, $limit = false);
global $asgarosforum;
$posts = $asgarosforum->profile->get_post_history_by_user($user_id, $limit = false);

 

@asgaros ย any example to use it? (i need to us it in a page out of asgaros plugin. i have a perfil page per user there i get (already done) post, comments, Q&A made by user in my web. I done care about CSS (i make it as my needs) only php snippets and the the count (count if is posible).

Thanks!

@adnan Basically the code reads all the post-data from the database and saves it into the $posts variable.

I dont exactly know what you want to build and how the components are working which you want to use, but you can have a look into the following implementation (it is how this function is used inside of the profile, which you could use as a template):

https://github.com/Asgaros/asgaros-forum/blob/master/includes/forum-profile.php#L168

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!
Quote from Asgaros on May 23, 2019, 9:24 pm

@adnan Basically the code reads all the post-data from the database and saves it into the $posts variable.

I dont exactly know what you want to build and how the components are working which you want to use, but you can have a look into the following implementation (it is how this function is used inside of the profile, which you could use as a template):

https://github.com/Asgaros/asgaros-forum/blob/master/includes/forum-profile.php#L168

i want to get this list: https://asgaros.com/support/history/adnan/ ย for a custom post type i do something like this and get it any post type:

<?php
          $args = array(
              'post_type'  => 'dwqa-answer',
              'author'     => $user->id,
     		       'post_status' => 'publish',
     		       'posts_per_page' => 5,
          );
          $wp_posts = get_posts($args);
          if (count($wp_posts)) {
            echo '<h3>Respuestas (' . $count1 . ')</h3>';
 			 		   $loop = new WP_Query( $args );
 			 		   while ( $loop->have_posts() ) : $loop->the_post();
            ?>
           
             <div class="post-title box">
                        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>  <em><?php the_time('Y-m-d g:i:s G') ?></em>
                   <span><p><?php the_excerpt();?></p></span>
                   </li>
                     </div>

     		  <?php endwhile;
 			 		   wp_reset_postdata();
 			 					}
          ?>

I get all user posts, data, comments, Q&A and the asgaros forum is last step to end my perfil page ๐Ÿ™‚

Adnan has reacted to this post.
Adnan

Hi @adnan

You can use a loop on the forum-posts like the following:

global $asgarosforum;
$posts = $asgarosforum->profile->get_post_history_by_user(12345, true);

if (empty($posts)) {
    _e('No posts made by this user.', 'asgaros-forum');
} else {
    foreach ($posts as $post) {
        // Render your output here ...
    }
}

The 12345 example-ID must be replaced by the current user-ID of course. Inside of the foreach-loop you have to put your HTML to render the data.

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!
Quote from Asgaros on May 24, 2019, 1:06 pm

Hi @adnan

You can use a loop on the forum-posts like the following:

global $asgarosforum;
$posts = $asgarosforum->profile->get_post_history_by_user(12345, true);

if (empty($posts)) {
    _e('No posts made by this user.', 'asgaros-forum');
} else {
    foreach ($posts as $post) {
        // Render your output here ...
    }
}
  1. global $asgarosforum;
  2. $posts = $asgarosforum>profile>get_post_history_by_user(12345, true);
  3. if (empty($posts)) {
  4. _e(‘No posts made by this user.’, ‘asgaros-forum’);
  5. } else {
  6. foreach ($posts as $post) {
  7. // Render your output here …
  8. }
  9. }
global $asgarosforum;
$posts = $asgarosforum->profile->get_post_history_by_user(12345, true);

if (empty($posts)) {
    _e('No posts made by this user.', 'asgaros-forum');
} else {
    foreach ($posts as $post) {
        // Render your output here ...
    }
}

The 12345 example-ID must be replaced by the current user-ID of course. Inside of the foreach-loop you have to put your HTML to render the data.

My problem was here “$user_id” it was always return 0, so i add $user_id = $user->id; and now i am getting user id correctly Thanks a Lot !! going to make the loop ๐Ÿ™‚ thanks again.

Asgaros has reacted to this post.
Asgaros

I am happy to hear that the code is working well now! ๐Ÿ™‚

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

Every thing working in Loop!!

Thanks!!

Asgaros has reacted to this post.
Asgaros
PreviousPage 2 of 2