wordpress ACF create front end form, submit and edit — March 8, 2017

wordpress ACF create front end form, submit and edit

always add acf_form_head(); in head tag
acf_form_head();

$options = array(
'post_id' => $_GET['listing_edit'], // $user_profile,
'field_groups' => array(1199),
'submit_value' => 'Submit',
// ‘uploader’ => ‘basic’,
'class' => 'btn green'

);

acf_form( $options );

$value = get_field( 'add_feed_links_here', $_GET['listing_edit'] );
print_r($value);

And to add validation to this field
add_filter('acf/validate_value/name=add_feed_links_here', '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;

}

// load image data
$data = wp_get_attachment_image_src( $value, 'full' );
$width = $data[1];
$height = $data[2];

if( $width < 960 ) {

$valid = 'Image must be at least 960px wide';

}

// return
return $valid;

}
Every Information about ACF, using field keys — February 14, 2017