do_shortcode workaround or rewrite rule support
-
Hi,
First of all thanks for the great plugin!
I’m building a members directory with 2 Xprofile custom fields, I have two very important filters on these custom fields:
-Service
-Location (state)Users can search easily search for a service in their region. So far so good!
I really, really need static pages / pretty permalinks for SEO purpose, in my case like this:https://site.com/service/doctors/
https://site.com/service/doctors/location/new-york/I have been trying for days now, but can’t get it done. Tried several things, without any luck. Any help would be highly appreciated, and if I get it working I’ll be glad to share my code because I think a lot of people would love to have this functionality too.
———-
My first try failed:
At first sight, I thought that I could fix this relatively easily by making my custom function…
-Create custom user directory by adding form shortcode to a page.
-Then I added custom rewrite rules to catch the query variables with pretty permalinks.
-Wrote a custom function that passed the dynamic query vars to your bps_directory shortcode do_shortcode function.But then I found out that the do_shortcode function won’t work on your plugin. So I’m stuck.
My question:
Is it possible to call your functions other than with shortcode or do_shortcode form within my own function, so I can pass the variables? Hopefully you can think of something to point me in the right direction?———-
My second try failed:
I found this post where you explained how to set default values: https://www.ads-software.com/support/topic/default-value-14/. I am able to catch custom field values with get_query_var() function and pass it to the form with the function you provided.If I visit my directory on https://site.com/custom-directory/, and I filter, this results in this URL:
https://site.com/custom-directory/?field_36=doctors&filed_37=new-york&bps_form=831&bps_form_page=%2Fprofessionals%2FSo I was happy and thought it was just a matter of using the add_rewrite_rule() function. add_rewrite_rule(‘^service/([^/]*)/location/([^/]*)/?’, ‘index.php?pagename=custom-directory&field_36=$matches[1]&field_37=$matches[2]&bps_form=831′,’top’);
However, when I visit the site at https://site.com/service/doctors/location/new-york/, the page loads, and the form is inserted. However, the code for the results is missing.After investigating, I found that this is caused by the bps_current_page() function from your script. When using rewrites, this code returns empty $_SERVER[‘HTTP_REFERER’] and $_SERVER[‘REQUEST_URI’];
I’ve been trying for hours and been thinking of a way to bypass the bps_current_page function or build in another check and additional function there to determine if we are on a directory page if those variables return empty.
Do you think there is a workaround to make it work in the above situation? Hopefully you can think of something to point me in the right direction?
———-
The only solution I can think of now to get it working out-of-the-box is by setting hidden fields depending on the page that’s being visited. But then I have to manually create thousands of custom directory pages. I have 12 regions x 250 services, resulting in 3000 pages that I have to create.Sorry for the long post ?? and thanks in advance, any help is appreciated!
Cheers! Bas
- The topic ‘do_shortcode workaround or rewrite rule support’ is closed to new replies.