Solved with:
add_filter('acf/prepare_field/key=field_5a93cdad837af', function($field){
if(in_array(CURRENT_USER_ROLE, array('administrator','owner'))){
return $field;
}
return false;
});
Hi Eliot,
Why is not official plugin or feature to cleanup this automatically?
Solved with this piece of code:
// jQuery
wp_enqueue_script('jquery');
// This will enqueue the Media Uploader script
wp_enqueue_media();
?>
<div>
<label for="image_url">Image</label>
<input type="text" name="image_url" id="image_url" class="regular-text">
<input type="button" name="upload-btn" id="upload-btn" class="button-secondary" value="Upload Image">
</div>
<script type="text/javascript">
jQuery(document).ready(function($){
$('#upload-btn').click(function(e) {
e.preventDefault();
var image = wp.media({
title: 'Upload Image',
// mutiple: true if you want to upload multiple files at once
multiple: false
}).open()
.on('select', function(e){
// This will return the selected image from the Media Uploader, the result is an object
var uploaded_image = image.state().get('selection').first();
// We convert uploaded_image to a JSON object to make accessing it easier
// Output to the console uploaded_image
console.log(uploaded_image);
var image_url = uploaded_image.toJSON().url;
// Let's assign the url value to the input field
$('#image_url').val(image_url);
});
});
});
</script>
From: http://stackoverflow.com/questions/17668899/how-to-add-the-media-uploader-in-wordpress-plugin
Hi, I dont want use WordPress type plugin of Image Map Pro, only jquery type plugin integrate somehow into newly created acf field type. Most interaction will be with my own javascript realised.
Question: How I can use ACF Image choose/upload button in my new acf field type? Maybe is some code example?
Hi, maybe You can show some full code about this stuff? I creating one system where must be places spliced by divisions. Each division can have several floors, to which will be assigned maps with placemarkers.
Can You help me somehow? Will be cool, to see yours code adopted to acf fields…
Solved here: Topic
Solved with your provided explanation. Thanks James!
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.