Finally, I did it adding edit_published_pages
capability.
Finally, I did it adding edit_published_pages
capability.
This still doesn’t for me. I changed the permission to like this:
add_action('wp', 'allow_employer_uploads');
function allow_employer_uploads() {
$employer = get_role('employer');
// author caps
$employer->add_cap('edit_published_posts');
$employer->add_cap('delete_posts');
$employer->add_cap('edit_posts');
$employer->add_cap('upload_files');
// editor caps
$employer->add_cap('edit_others_posts');
}
Hi, Same problem here. Not sure how this worked. I am not using the plugin https://wordpress.org/plugins/theme-my-login/ so where and how the codes should go?
File upload works fine from backend when logged in as a user.
I changed the user permission to below:
add_action('wp', 'allow_employer_uploads');
function allow_employer_uploads() {
$employer = get_role('employer');
// author caps
$employer->add_cap('edit_published_posts');
$employer->add_cap('delete_posts');
$employer->add_cap('edit_posts');
$employer->add_cap('upload_files');
// editor caps
$employer->add_cap('edit_others_posts');
}
Thanks
Thanks John and Jeff,
So the $field
parameter is actually an array like below:
array(23) {
["ID"]=>
int(0)
["key"]=>
string(15) "_validate_email"
["label"]=>
string(14) "Validate Email"
["name"]=>
string(20) "acf[_validate_email]"
["prefix"]=>
string(3) "acf"
["type"]=>
string(4) "text"
["value"]=>
string(0) ""
["menu_order"]=>
int(2)
["instructions"]=>
string(0) ""
["required"]=>
int(0)
["id"]=>
string(0) ""
["class"]=>
string(0) ""
["conditional_logic"]=>
int(0)
["parent"]=>
int(0)
["wrapper"]=>
array(4) {
["width"]=>
string(0) ""
["class"]=>
string(0) ""
["id"]=>
string(0) ""
["style"]=>
string(24) "display:none !important;"
}
["_name"]=>
string(15) "_validate_email"
["_prepare"]=>
int(1)
["_valid"]=>
int(1)
["default_value"]=>
string(0) ""
["maxlength"]=>
string(0) ""
["placeholder"]=>
string(0) ""
["prepend"]=>
string(0) ""
["append"]=>
string(0) ""
}
I have been able to do some awesome thing :
function viz_acf_prepare_field($field){
$userid = get_current_user_id();
$user = new Viz_Author($userid);
if ( ! is_admin() ) :
if ( $field['_name'] == 'client' || $field['_name'] == 'template' ) {
return false;
}
if ( $field['_name'] == 'project_template' ) {
$field['disabled'] = 1;
$field['wrapper']['class'] = 'viz_hidden';
$field['value'] = $user->template;
}
endif;
return $field;
}
add_filter('acf/prepare_field', 'viz_acf_prepare_field');
In the above code, client
and template
don’t display at the front-end form, and project_template
is disabled with a selected value and custom class.
Thank you all
Enqueuing wp_enqueue_media()
will fixed the [Error] TypeError: undefined is not an object (evaluating ‘wp.media.query’) error.
But you may still need to a plugin like ‘User role editor’, ‘User Access Manager’ to enable user access to the media library.
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.