Where di I find posts from forum user?
Quote from Sara on January 14, 2019, 11:20 pmQuote from Asgaros on August 21, 2018, 12:10 pm…
If you are a developer you can get the post-data of a user via the $asgarosforum->content->get_posts_by_author($author_id) function.
Ok, I found a snippet of code from Ultimate Member that lets you add tabs to a user’s UM profile menu and I’ve tried to implement your post-data code in their code but it’s not working. No surprise there… I know just enough PHP to get myself into trouble.
What did I do wrong? Is it a simple fix, or is this one of those things that’s more complicated than what I think it is.
/* ADD TAB TO ULTIMATE MEMBER PROFILE - This extends main profile tabs */ add_filter('um_profile_tabs', 'add_custom_profile_tab', 1000 ); function add_custom_profile_tab( $tabs ) { $tabs['mycustomtab'] = array( 'name' => 'My Forum Posts', 'icon' => 'um-faicon-comments', ); return $tabs; } /* Then we just have to add content to that tab using this action */ add_action('um_profile_content_mycustomtab_default', 'um_profile_content_mycustomtab_default'); function um_profile_content_mycustomtab_default( $args ) { return $asgarosforum->content->get_posts_by_author($author_id); }I hope you can see what I’m trying to do here.
Quote from Asgaros on August 21, 2018, 12:10 pm…
If you are a developer you can get the post-data of a user via the $asgarosforum->content->get_posts_by_author($author_id) function.
Ok, I found a snippet of code from Ultimate Member that lets you add tabs to a user’s UM profile menu and I’ve tried to implement your post-data code in their code but it’s not working. No surprise there… I know just enough PHP to get myself into trouble.
What did I do wrong? Is it a simple fix, or is this one of those things that’s more complicated than what I think it is.
/* ADD TAB TO ULTIMATE MEMBER PROFILE - This extends main profile tabs */ add_filter('um_profile_tabs', 'add_custom_profile_tab', 1000 ); function add_custom_profile_tab( $tabs ) { $tabs['mycustomtab'] = array( 'name' => 'My Forum Posts', 'icon' => 'um-faicon-comments', ); return $tabs; } /* Then we just have to add content to that tab using this action */ add_action('um_profile_content_mycustomtab_default', 'um_profile_content_mycustomtab_default'); function um_profile_content_mycustomtab_default( $args ) { return $asgarosforum->content->get_posts_by_author($author_id); }
I hope you can see what I’m trying to do here.
Quote from Asgaros on January 14, 2019, 11:43 pmHello @sara
I didnt have time to look into the UM-API yet (currently I am still working on the BuddyPress-integration first).
I guess that the arguments in the $args variable of the um_profile_content_mycustomtab_default() function contains the user-id somewhere. This ID must be given to the get_posts_by_author() function. But then it will get tricky because I have no clue yet on how UM works internally.
The get_posts_by_author() returns all posts of the user – that means it could be thousands when your community is big. So what is needed is some kind of pagination which makes it more easier for your user to navigate through them. I guess that UM maybe automatically creates this based on the returned data, but I am not sure. The returned data also must get rendered. I dont know if UM has some rendering-functions for this to display the data or even if the data must be in a specific format for this.
So as you can see this requires a little bit more of in-depth knowledge on how UM works internally. I hope that I can take a closer look into it soon but I cant promise that it will be very soon. Third-party plugin-integrations are always a little bit difficult for a one-person-project. As a developer I have to ensure that it works with every version of Asgaros Forum, of WordPress and of UM whenever there is a new update. You can imagine that this will become a time-consuming process – especially when more and more third-party plugin-integrations will become available.
Hello @sara
I didnt have time to look into the UM-API yet (currently I am still working on the BuddyPress-integration first).
I guess that the arguments in the $args variable of the um_profile_content_mycustomtab_default() function contains the user-id somewhere. This ID must be given to the get_posts_by_author() function. But then it will get tricky because I have no clue yet on how UM works internally.
The get_posts_by_author() returns all posts of the user – that means it could be thousands when your community is big. So what is needed is some kind of pagination which makes it more easier for your user to navigate through them. I guess that UM maybe automatically creates this based on the returned data, but I am not sure. The returned data also must get rendered. I dont know if UM has some rendering-functions for this to display the data or even if the data must be in a specific format for this.
So as you can see this requires a little bit more of in-depth knowledge on how UM works internally. I hope that I can take a closer look into it soon but I cant promise that it will be very soon. Third-party plugin-integrations are always a little bit difficult for a one-person-project. As a developer I have to ensure that it works with every version of Asgaros Forum, of WordPress and of UM whenever there is a new update. You can imagine that this will become a time-consuming process – especially when more and more third-party plugin-integrations will become available.