Thanks John! I was using CPT plugin to register post types and it must of been conflicting somewhere. I manually set up CPT’s and it now works, thanks John!
This is my CPT registration code:
add_action( 'init', 'cptui_register_my_cpts_gallery' );
function cptui_register_my_cpts_gallery() {
$labels = array(
"name" => __( 'Gallery', '' ),
"singular_name" => __( 'Gallery', '' ),
);
$args = array(
"label" => __( 'Gallery', '' ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => true,
"rest_base" => "",
"has_archive" => true,
"show_in_menu" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => array( "slug" => "gallery", "with_front" => true ),
"query_var" => true,
"menu_position" => 5,
"supports" => array( "title", "thumbnail" ),
"taxonomies" => array( "category", "post_tag" ),
);
register_post_type( "gallery", $args );
}
hmm do you have any other CPT settings, I have "has_archive":"true"
Im using PRO 5.4.4 which includes Archives but its not displaying Custom post type Archives, any ideas?
Hi I also need this feature, so paste in a video mp4 link and it previews as an html5 video in the backend, did you find a solution?
I’ve found wp remote get
and wp remote post
which run GET or POST requests, I’ve wrapped a GET URL string in acf/save_post
as you’ve suggested like so
function my_acf_save_post( $post_id ) {
// bail early if no ACF data
if( empty($_POST['acf']) ) {
return;
}
// bail early if editing in admin
if( is_admin() ) {
return;
}
// specific field value
$field = $_POST['acf']['field_000000000'];
$urlgetstring = "http://site.com/index.php?answer1=field";
//send GET request
wp_remote_get( $urlgetstring );
}
// run before ACF saves the $_POST['acf'] data
add_action('acf/save_post', 'my_acf_save_post', 1);
Thanks for the point in the right direction!
thanks John
I’ve got the form data retuning before the form data is saved, now I just need to figure out how to send the out as a url string
I’m submitting the form values to a third party which have preset variables for the input name field so I’m looking to get the acf fields to match this, at the moment my input fields look like:
<input id="acf-field_5644ca0ecae0b" class="" type="text" placeholder="" value="" name="acf[field_5644ca0ecae0b]">
I need input name to be something like:
<input id="acf-field_5644ca0ecae0b" class="" type="text" placeholder="" value="" name="answer1">
i can achieve this with jquery but doing this stops the data being being sent to the new post which is also made by the form, I either need acf to use custom field keys or look into acf/save_post filter
Thanks so much
I set up allowed file types in custom fields backend however it doesn’t seem to validate when I use the basic uploader.
Why does t need to check if it’s numeric?
Im using acf/validate_value
passing wp_check_filetype
to make sure images uploaded via a front end form are image types, the code below is working perfectly on the front end, however when I go to publish the post created by the form in the backend (as its automatically saved as a draft) I get the error message for when it is not a accpeted file type , when it is.
My question is how do you use acf/validate_value
to check that the file uploaded is an image type, I am using the Basic file uploader so guests can upload images
//FORM IMAGE VALIDATION
add_filter('acf/validate_value/name=image_upload', 'my_acf_validate_value', 10, 4);
function my_acf_validate_value( $valid, $value, $field, $input ){
// bail early if value is already invalid
if( !$valid ) {
return $valid;
}
$filetype = wp_check_filetype($value);
$filetypeext = $filetype['type'];
if( $filetypeext != 'image/jpeg' && $filetypeext != 'image/gif' && $filetypeext != 'image/png' && $filetypeext != 'image/bmp'&& $filetypeext != 'image/tiff' && $filetypeext != 'image/jpg') {
$valid = "Please upload a valid image file!";
}
// return
return $valid;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.