ACF get Taxonomy Term meta — September 27, 2017

ACF get Taxonomy Term meta

ACF saves Taxonomy Term meta in wp_options table and here is how u can access it.

$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;

$value = get_field( 'test_field', $taxonomy.'_'.$term_id);
if( $value ) {
    echo $value;
} else {
    echo 'empty';
}
Advertisements
acf_form() after form submit handler — September 4, 2017

acf_form() after form submit handler

Here is one filter which can help you

add_filter('acf/pre_save_post' , 'my_pre_save_post' );
function my_pre_save_post( $post_id ) {
    //do whatever u want to do here
    //dont forget to return $post_id
    return $post_id;
}

For better information check this link.

Also need to make it more selective otherwise this will work for all acf_forms

add_filter('acf/pre_save_post' , 'my_pre_save_post' );
function my_pre_save_post( $post_id ) {
        print_r($GLOBALS['acf_form']);	
	$current_user = wp_get_current_user();
	$user_id = $current_user->ID;
	if($GLOBALS['acf_form']['post_id'] == 'user_'.$user_id)
	{
		$GLOBALS['acf_form']['return'] = site_url().'/owners-add-new-property/?step=started';
		update_user_meta($user_id, "current_profile_step", 4);
	}
	return $post_id;
}

You can see some unique info in ‘$GLOBALS[‘acf_form’]’ which will be unique for this post request. If still u have question add comment , will try to reply :).

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