I understand now that my PHP should use “return” instead of “echo” or “print”; but is it as simple as finding and replacing echo with return?
Sorry, not a PHP expert…but I can follow instructions.
I am having the same issue as stickers11 and I also am not a php expert. It is simple to use and set up. However, even though I post the content before the form the page still defaults to putting the form first. Please either explain how to fix this or offer a fix. Every other plugin I use with short code doesn’t have this issue.
I was having the same issue. Below are my modifications to the ajax_contact_form function in ajaxcf.php that resulted in the ability to post content before the shortcode.
[Code moderated as per the Forum Rules. Please use the pastebin]
Hi, as forced_request says, you can open ajaxcf.php in any editor and change the last function called ajax_contact_form() just replace from the comment to the end with this:
// add contact form
function ajax_contact_form(){
global $wpdb;
$table_name = $wpdb->prefix . "design_form";
$myrows = $wpdb->get_results("select * from $table_name order by torder ASC");
$out = '<form id="ajaxForm">';
foreach($myrows as $myrow) { if($myrow->tname=='input') {
$out.= '<p>';
$out.= '<label for="' . $myrow->tid .'">' . $myrow->value .':</label>';
$out.= '<input id="'. $myrow->tid .'" name="' . $myrow->name . '" value="' .$myrow->value . '" type="text" />';
$out.= '</p>';
} else {
$out.= '<p>';
$out.= '<label for="'. $myrow->tid .'">'. $myrow->value .':</label>';
$out.= '<textarea id="'. $myrow->tid .'" name="'. $myrow->name .'">'.$myrow->value.'</textarea>';
$out.= '</p>';
}
}
$out.= '<p>';
$out.= '<label for="check">Want a copy of this mail to your address?:</label>';
$out.= '<input id="check" name="check" type="checkbox" />';
$out.= '</p>';
$out.= '<p class="submit">';
$out.= '<input name="action" type="hidden" value="ajaxcf" />';
$out.= '<input id="submit_button" value="Send" type="button" onClick="submit_me();" />';
$out.= '</p>';
$out.= '</form>';
return $out;
}
add_shortcode("ajaxcf", "ajax_contact_form");
?>
hope this helps.
Cheers