Notifications
Clear all

wpForo 1.x.x [Closed] Direct link to add topic button

9 Posts
4 Users
0 Reactions
1,416 Views
Posts: 8
Topic starter
(@anthonyw)
Active Member
Joined: 4 years ago

Hi,

I want to put a direct link to create a topic inside of a forum.  However, I can't find a slug or URL for posting as a standalone page, rather than the ajax/js driving solution right now.  

If anyone can advise either how to trigger the add topic button immediately after a page load or more simply how to link directly to an add topic page, that would be wonderful.

Thank you.

8 Replies
Posts: 988
Moderator
(@martin)
Support Team
Joined: 8 years ago

Just use that forum URL.

For example, this URL goes to "How-to and Troubleshooting" forum, where you can see [Add Topic] button.

https://wpforo.com/community/how-to-and-troubleshooting-2/

 

Posts: 8
Topic starter
(@anthonyw)
Active Member
Joined: 4 years ago

Hi,

 

Yes, but in that solution, the user still has to find the "add topic" button.  IMHO, the current layouts are very busy, and if you don't know what you're looking for, it can be a lot to ask a flight risk "new user".  So, I'm trying to circumvent that by including a "Ask a question" link in my main navigation, which ideally, immediately loads up the add topic form directly on the forum. 

 

I did perform a search before asking and am doubtful there is currently a solution, but I appreciate you guys advise on how you would tackle on my end if you were to do this.  

 

 

 

(Relevant search pages just for reference...

https://wpforo.com/community/how-to-and-troubleshooting-2/how-to-add-add-topic-button-to-the-forum-menu-or-forum-main-dashboard/#post-28590

https://wpforo.com/community/how-to-and-troubleshooting-2/can-the-add-topic-form-have-its-own-url-rather-than-opening-up-within-other-pages-how/#post-35926

)

Posts: 8
Topic starter
(@anthonyw)
Active Member
Joined: 4 years ago

I got it.  I added a little JS to a new text widget in my theme.  I had to turn on allowing anonymous posting (obviously, but it didn't occur to me at first).  If you have a better way, I'd love to hear. 

 

<script type="text/javascript">
function custom_wpforo_add_a_topic(){
  if( (window.location.pathname + window.location.search) == '/discussions/questions/?ask-a-question'){
document.getElementById('add_wpftopic').click()
  }
}
jQuery(document).ready(function(){
  return custom_wpforo_add_a_topic();
});
</script>

3 Replies
xfok
 xfok
(@xfok)
Joined: 5 years ago

Estimable Member
Posts: 79

@anthonyw Can you share ur site? i will see solution

 

(@anthonyw)
Joined: 4 years ago

Active Member
Posts: 8

@xemanuelex Sure, it's at https://govtbasics.com   then click on the "Ask a Question" on the top right navigation.

(I'm just now starting to play with this site so don't judge it yet!!!)

I attached the widget too for reference.

 

(@anthonyw)
Joined: 4 years ago

Active Member
Posts: 8

@xemanuelex My parent comment went under moderation when I edited, so I'm not sure if it pinged you.  Going to do again just to make sure.  hope it helps! 

 

Posts: 8
Topic starter
(@anthonyw)
Active Member
Joined: 4 years ago

Hi,

 

After the last wpforo update, I had to make a couple changes.  I thought I'd go ahead and share.  (Remember, if you use this code, you have to change the URL to your URL.  My URL is "/discussions/questions/"  and I used a Custom Link in my menu to add the "?ask-a-question" part.  

 

Base JS:

function custom_wpforo_add_a_topic(){

var el = document.getElementById('add_wpftopic')
console.log('Did we find the wpforo new topic button element?')

if(typeof(el)== 'undefined' || el == null){
console.log('no :(')
return false
}

if( (window.location.pathname + window.location.search) == '/discussions/questions/?ask-a-question')
{
console.log('Yes!')
el.click()
return true
}

}

jQuery(document).ready(function(){
setTimeout(custom_wpforo_add_a_topic, 1000)
});


Minified for the widget (it was inserting paragraph tags...):
<script type="text/javascript">function custom_wpforo_add_a_topic(){var o=document.getElementById("add_wpftopic");return console.log("Did we find the wpforo new topic button element?"),void 0===o||null==o?(console.log("no :("),!1):window.location.pathname+window.location.search=="/discussions/questions/?ask-a-question"?(console.log("Yes!"),o.click(),!0):void 0}jQuery(document).ready(function(){setTimeout(custom_wpforo_add_a_topic,1e3)});</script>

 

Page 1 / 2