Hi,
i use gf to let the User populate Postings. I want to prevent them to Post "similar Content" (like the "Similar Topics" Box here). Can i use something similar to show the User (dynamicle) such Postings?
joerg
Hi,
i use gf to let the User populate Postings. I want to prevent them to Post "similar Content" (like the "Similar Topics" Box here). Can i use something similar to show the User (dynamicle) such Postings?
joerg
I'm sorry, I don't understand what you are looking for.
Sorry, my english isn't good. I try it again. If I start a topic in this forum, then tests the forum if there is a similar topic already. I want a similar function for my form. Use the form to send user entries for the website and I'd like to suppress duplicate entries.
This is my form: http://www.gwinnr.de/ess-gewinnspiel-melden-2
After the User is chosing "Anbieter" i would to show postings with the same "Anbieter" in the box below.
Gravity Forms doesn't support showing entries in the front end of a site unless you make them WordPress posts through our Post Fields and then you could use a related posts plugin to pull in such details.
If you wanted to do this without Post Fields, you'll have to custom code the PHP / SQL statements to do so. All my best!
Okay, i unterstand that there is no "out of the box" solution there. I try now to make my on solution and got one question: where can i modify a field with a "onChange" (Javascript) method?
Sure, you can watch remote fields using JS for an update, but you can't change the field code itself. All my best! Happy holidays!
okay ... i spend the last four hours on the problem and solved it. The trick was admin-ajax, a html Element in the form, some jquery code and a custom query in the functions.php.
You can close the topic
Happy holidays!
@schnettker, can you share your code here please for the benefit of others who may want to accomplish the same thing? Thank you.
okay .... here comes some code. The code needs additionaly security checks! (proof the _POST Variable!)
function.php (called by the javascript code)
function AjaxSimilar(){
//get the data from ajax() call
$anbieter = $_POST['anbieter'];
$query = new WP_Query( array( 'taxonomy'=>'anbieter', 'anbieter' => $anbieter) );
while ( $query->have_posts() ) :
$query->the_post();
$results = $results .'<li>'.get_post_meta(get_the_ID(), 'einsendeschluss', true). ' - <strong>'.$anbieter.'</strong> - ' . get_the_title() . '</li>';
endwhile;
if (!$query->have_posts())
{
$results = '<strong>No posts</strong>';
}
die($results);
}
// creating Ajax call for WordPress
add_action( 'wp_ajax_nopriv_AjaxSimilar', 'AjaxSimilar' );
add_action( 'wp_ajax_AjaxSimilar', 'AjaxSimilar' );
Javascript (header.js.php in my template)
$( document ).ready( function( $ ) {
$('.anbieter').bind('change', function (){
jQuery.ajax({
type: 'POST',
url: 'http://www.gwinnr.de/wp-admin/admin-ajax.php',
data: {
action: 'AjaxSimilar',
anbieter: $('.anbieter div').find('span').text(),
},
success: function(data, textStatus, XMLHttpRequest){
$('.similarbox').html('');
$('.similarbox').append(data);
},
error: function(MLHttpRequest, textStatus, errorThrown){
alert(errorThrown);
}
});
});
In my example i build a html form with the css class "similarbox" and a select with advanced controller with the css class "anbieter"
The result is visible at http://www.gwinnr.de/ess-gewinnspiel-melden-2
Neat solution: thank you for sharing your code.