#1 WordPress forum plugin created by gVectors Team

wpForo – WordPress Forum Plugin
  • Home
  • Forum
  • Migrate to wpForo
  • Addons
  • Documentation

Forum

Home | Forum

wpDiscuz - WordPress Comment Plugin
  • Forums
  • Members
  • Recent Posts
Forums
Main Support Forums
wpForo Integration
Integration with Se...
 
Share:
Notifications
Clear all

[Solved] Integration with Search Analytics  

    Last Post
RSS

cornelRaiu
Posts: 4
 cornelRaiu
Topic starter
July 7, 2020 7:38 am
(@cornelraiu)
New Member
Joined: 7 months ago

Hello,

My name is Cornel and I am the developer of the Search Analytics plugin. 

I recently got a request from a user who asked me to integrate wpForo with my plugin. I was trying to do that, howerer, I came across one issue that prevents me from doing the integrations.

The way my plugin works is this: it captures a search string from the params and stores it in the database along with the number of results from the search and then it displays search statistics for the website. However, due to the way search is implemented in wpForo, I am not able to pull the search results count from the queries wpForo does without hook deep into the WP query filters.

I went through the plugin and it looks like the thing I need to be able to integrate it is the following:

In the file `class-posts.php` I would need an action like:

$sql = "SELECT COUNT(*) FROM ". $from ." ".implode(' ', $innerjoins);
if($wheres) $sql .= " WHERE " . implode( " AND ", $wheres );
$items_count = (int) WPF()->db->get_var($sql);

do_action( 'the_action_name', $items_count, $sql );


======= or, even better =======

if( $args['row_count'] ) $sql .= " LIMIT ". intval($args['offset']) ."," . intval($args['row_count']);

$posts = WPF()->db->get_results($sql, ARRAY_A);

do_action( 'the_action_name',
$items_count, $results, $sql );

This way I will be able to get the total posts resulting in the search with all the options from wpForo or just get the query and run it with small changes to accommodate the needs in the analytics system.

If this is not possible, I will hook into the `query` WordPress filter and get the query from there. But I'd prefer not to so because I don't want to run the query a second time.

Looking forward to your reply!

Thank you

Topic Tags
Search Analytics search search hook action hook
4 Replies
Robert
Posts: 7564
 Robert
Admin
July 7, 2020 8:26 am
(@robert)
Support Team
Joined: 5 years ago

Hi @cornelraiu,

Thank you for contacting us. We've just added an action hook called 'wpforo_search_result_after'. Here is the place and the arguments:

 

$args: The search query:

$args = array( 
'needle' => '', // search phrase
'forumids' => array(), // array( 2, 10, 25 )
'date_period' => 0, // date period filter
'type' => 'entire-posts', // search type ( entire-posts | titles-only | user-posts | user-topics | tag )
'orderby' => 'relevancy', // search mode by ( relevancy | date | user | forum )
'order' => 'DESC', // search order ( ASC | DESC )
'offset' => NULL, // query offset
'row_count' => NULL // max number of result per page
);

 

$items_count: The total number of search result

$posts: An array of search result posts for current page

$sql: SQL query

In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

fawp and cornelRaiu liked
cornelRaiu
Posts: 4
 cornelRaiu
Topic starter
July 7, 2020 8:38 am
(@cornelraiu)
New Member
Joined: 7 months ago

Hi @robert,

Thank you for the quick reply. That action is exactly what I need to be able to integrate with my plugin.

When should we expect an update for the plugin that would roll-out with this change?

Thank you!

1 Reply
Robert
 Robert
Admin
(@robert)
Joined: 5 years ago

Support Team
Posts: 7564
July 7, 2020 8:55 am
Reply tocornelRaiucornelRaiu

@cornelraiu,

We're planning to release it next week.

In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

fawp and cornelRaiu liked
cornelRaiu
Posts: 4
 cornelRaiu
Topic starter
July 7, 2020 8:57 am
(@cornelraiu)
New Member
Joined: 7 months ago

@robert,

Thank you!

  All forum topics
  Previous Topic
Next Topic  
Related Topics
  • WP search and wpForo search integration
    2 years ago
Topic Tags:  Search Analytics (1), search (12), search hook (1), action hook (1),

Forum Search

Join Us!

Download wpForo plugin
on WordPress.org

wpForo Addons

wpforo-private-messages  wpforo-advanced-attachments-128x128  wpforo-embeds-128x128 wpForo User Custom Fields addon  wpForo – Blog Cross Posting addon  wpForo Ads Manager
View all Addons »

Recent Topics

  • Affichage problématique des vues wpforo Sujets

    By exode13, 46 mins ago

  • Unread topics not going to first unread post

    By sazdoes, 4 hours ago

  • Change Main Forum Titles Font Size & Make Bold

    By RapiD3Dme, 10 hours ago

  • [Help] How To Remove The Hamburger Icon From Mobile Browser And Show The Full Menu

    By xcoleman17, 14 hours ago

  • Export Forum Posts into PDF File

    By dinak, 19 hours ago

  • Vote bug

    By xfok, 20 hours ago

Topic Tags

  • new features43
  • seo39
  • translation36
  • plugin conflict35
  • forum32
  • buddypress31
  • login31
  • threaded layout30
  • registration29
  • ultimate member28
  • moderation27
  • editor25
  • avatar24
  • shortcode23
  • css23
  • tags21
  • menu21
  • migration20
  • url20
  • profile20
View all tags (1471)

Recent Posts

  • RE: Affichage problématique des vues wpforo Sujets

    Hi @exode13, Please read this support topic. The same...

    By Sofy, 32 mins ago

  • Unread topics not going to first unread post

    I posted about this before, but it's still an issue and...

    By sazdoes, 4 hours ago

  • RE: How to customize the recent topic widget in sidebar.

    1.How to make identification for selected users? I have...

    By Maddyssonn, 4 hours ago

  • RE: login issue

    @mb_munich, I don't see the mean to use BuddyPress re...

    By Robert, 4 hours ago

  • RE: Private Forum Groups for WPForo

    You should edit each 200 forums and set "No Access" for...

    By Robert, 5 hours ago

  • RE: Export Forum Posts into PDF File

    Hi @dinak, Please check out this article, it should b...

    By Sofy, 7 hours ago

  • RE: Changes in subcategories

    @oksana, We're really sorry, but this issue cannot be...

    By Sofy, 8 hours ago

Share:
  Forum Statistics
20 Forums
7,777 Topics
39 K Posts
7 Online
14.9 K Members

Latest Post: Affichage problématique des vues wpforo Sujets Our newest member: geltiz Recent Posts Unread Posts Tags

Forum Icons: Forum contains no unread posts Forum contains unread posts

Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed

Powered by wpForo | Copyright © 2016-2021 gVectors Team
Copyright Registration Service - Click here for more information or to register work
wpForo is Registered with the IP Rights Office
Copyright Registration Service

Ref: 4477265538
  • Home
  • Forum
  • Migrate to wpForo
  • Addons
  • Documentation