• Is there any way to integrate GeoMyWP with NinjaForms? I run a lost and found pet website, where users enter their lost pets’ information as well as their zip codes. I want visitors to be able to click on Lost Dogs, for example, and then enter their zip code and search radius to search their particular area. Is there any way to customize GeoMyWP so that when the user enters their zip code in NinjaForms, it uses that information?

    Thanks in advance,
    Michael Wilson

    https://www.ads-software.com/plugins/geo-my-wp/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Eyal Fitoussi

    (@ninjew)

    Hello Michael,
    Do you want to make the posts that created by NinjaForms searchable via GEO my WP search forms?

    Thread Starter hmgh

    (@hmgh)

    Yessir.

    Plugin Author Eyal Fitoussi

    (@ninjew)

    Take a look at this tutorial. It explains how to apply locations to GEO my WP when posting from the front end using WP User Front-end pro plugin.

    Using Ninja Forms ( or any other forms ) should be the same idea but you will need to use the hooks provided by Ninja Forms plugin,

    Thread Starter hmgh

    (@hmgh)

    Thank you Eyal. The tutorial is for using an address field. Would it work the same for using a zip code, and if so, would I just replace the word ‘address’ in the code with ‘zip’ or ‘zipcode’?

    Plugin Author Eyal Fitoussi

    (@ninjew)

    No, you don’t need to change the ‘address’.

    Instead, try passing an array ( instead of a string ) to the ‘address’ argument. something like:

    if ( function_exists( 'gmw_pt_update_location' ) ) {
        //setup geocoder args
        $args = array(
                'post_id'         => $post_id,
                'post_type'     => get_post_type( $post_id ), // change post_type to your own
                'post_title'      => get_the_title( $post_id ),
                'address'         => array(
                     'zipcode' => $zipcode
                )
        );
    
        //run geocoder function
        gmw_pt_update_location( $args );
    }
    Thread Starter hmgh

    (@hmgh)

    Well, I tried it, but no luck. I’m a total newbie when it comes to coding. The form field in NinjaForms for the zipcode is [ninja_forms_field id=165]. I am using a WordPress theme called Evolve, and I modified the functions.php file to this:

    <?php
    
    $evolve_themename = "evolve";
    
    if ( get_stylesheet_directory() == get_template_directory() ) {
    	define('EVOLVE_URL', get_template_directory() . '/library/functions/');
    	define('EVOLVE_DIRECTORY', get_template_directory_uri() . '/library/functions/');
    } else {
    	define('EVOLVE_URL', get_template_directory() . '/library/functions/');
    	define('EVOLVE_DIRECTORY', get_template_directory_uri() . '/library/functions/');
    }
    
    get_template_part( 'library/functions/options-framework' );
    get_template_part( 'library/functions/basic-functions' );
    get_template_part( 'library/functions/options' );
    
    function gmw_update_location_via_wpuf(  $post_id ) {
    
    	//make sure we have post ID
    	if ( !$post_id )
    		return;
    
    	//change meta_field_name to the custom field of the address field
    	$address = get_post_meta( $post_id, 'ninja_forms_field id=165', true );
    
    	//include geocoder file
    	include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' );
    
    	if ( function_exists( 'gmw_pt_update_location' ) ) {
    		//setup geocoder args
    		$args = array(
    				'post_id'         => $post_id,
    				'post_type'       => get_post_type( $post_id ), // change post_type to your own
    				'post_title'      => get_the_title( $post_id ),
    				'zipcode'         => $zipcode
    		);
    		//run geocoder function
    		gmw_pt_update_location( $args );
    	}
    }
    //update data of new post
    add_action('wpuf_add_post_after_insert', 'gmw_update_location_via_wpuf', 10, 1 );
    //update data when post updated
    add_action('wpuf_add_post_after_updated', 'gmw_update_location_via_wpuf', 10, 1 );
    
    ?>

    Perhaps you can spot something I did wrong?

    Thread Starter hmgh

    (@hmgh)

    Eyal, any suggestions on the code above? I tried using ninja_forms_field id=165, [ninja_forms_field id=165], changing the zipcode and $zipcode back to address and $address, but still no luck? Can anyone help?

    @hmgh

    I’m trying to find a solution to a similar problem (using a custom form to post bbpress topics)

    I *think* there’s 2 points to consider –

    1 – is “ninja_forms_field id=165” the actual name of the custom field that is created? I don’t think they can contain spaces so perhaps it’s actually something like ninja_forms_field_id_165? Or something similar, you’ll need to find that out.

    2 – this bit of code (“wpuf_add_post”) is I believe referencing an ‘action’ within the WP User Frontend plugin, which you are not using, so you need to find the equivalent ‘action’ used within the Ninja Forms plugin.

    add_action('wpuf_add_post_after_insert', 'gmw_update_location_via_wpuf', 10, 1 );
    //update data when post updated
    add_action('wpuf_add_post_after_updated', 'gmw_update_location_via_wpuf', 10, 1 );

    I hope I’m on the right track here, but haven’t yet been able to figure out how this will work with bbpress new topics.

    Good luck!

    Plugin Author Eyal Fitoussi

    (@ninjew)

    @ PinkishHue and @hmgh,
    There might be an easier way to do it. You can simply use the action hook save_post_{post-type} to run the function everytime a post created or updated.

    I just updated this doc with an example ( take a look at the first example ).

    Hi Eyal

    Thanks for your help. Like @pinkishhue and @hmgh, I use Ninja Forms and really like it. To make things easier for everyone, I would like to combine the power of Ninja Forms with that of the Google Places API or Geo my WP.

    In brief, I have multiple address fields in my Ninja Forms front end. At the moment, people need to enter their street number, their street type, their suburb name, their zipcode and choose their Australian state from a dropdown list. I would like to have only one address field where people would start typing their address in (e.g 1 Thomass…) and the plugin would immediately suggest a few relevant addresses that people could click on (eg 1 Thomasson St, Park Avenue, Qld 4701).

    Like @hmgh, all I have is something like ninja_forms_field id=165. I am happy to modify the function.php file of my theme file myself or even to finance your work to enable this if this is possible. Let me know if you are able to help.

    Kind regards
    Matt

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Integration with NinjaForms?’ is closed to new replies.