lewismcarey / user-field-acf-add-on Goto Github PK
View Code? Open in Web Editor NEWUser Field Add on for Advanced Custom Fields
User Field Add on for Advanced Custom Fields
Sorry - I know I should know this but to install the add on, I have uploaded it into my plugins folder, but where do I put the registration code? And if it is in my plugins folder are you able to give an example of what I might enter as the direct path please?
Thank you and sorry again!
James
Sorry - I know I should know this but to install the add on, I have uploaded it into my plugins folder, but where do I put the registration code? And if it is in my plugins folder are you able to give an example of what I might enter as the direct path please?
Thank you and sorry again!
James
The way Advanced Custom Fields v4.0 handles new fields has changed since v3.x
http://www.advancedcustomfields.com/resources/tutorials/creating-a-new-field-type/
Any chance you could store just the user ID, its making it impossible to query posts based on this field?
When i print out $values i get data for everything except user_description?
In addition to this would be really nice if we could grab the user gravatar if possible?
Hi,
this is a very nice plugin, but I found a issue in "filter by role".
I am working with the italian translation of Wordpress, and the query at line 225 ($users = get_users( $args )) always returns an empty array.
I notice that also the values of the select field are the translated ones, and I think this could be the reason.
Thank you,
Fabio
Hi Lewis,
I'm Elliot, the dev behind ACF and just wanted to say hi, thank you for making this field and also chat about the new ACF v4.
Unfortunately, in v4, I have had to change the way in which we define custom field types, this means your field is not compatible with the new ACF and wont work.
This said, it will not require much work at all to create a v4 compatible field type!
Please read the new documentation for creating a field type here:
http://www.advancedcustomfields.com/docs/tutorials/creating-a-new-field-type/
You will find that some functions have changed names. I advise that you start with a blank dummy.php field file and copy across your old functions one by one into the new function spaces.
I'm more than happy to help out with creating a v4 compatible field type, just let me know.
I'm not sure if you would want to create a new repository or just a new branch, but either way, both versions will need a url for users to find.
I'm sorry about causing any extra work and hassle, thanks for all your hard work, it's greatly appreciated!
Cheers
Elliot
Thanks for creating this extension. It's saving me tons of time.
Here's my code (it's within the author.php template).
ID ); $next = get_field('_user', 'user_'.$curauth->ID ); if ( !empty($prev) ) : print_r($prev); endif; if ( !empty($next) ) : print_r($next); endif; ?>This results in the following error:
Warning: Invalid argument supplied for foreach() in .../acf_users_field.php on line 407
I have a single user selected for each of the fields, but get this error no matter what I do. Any ideas?
Thanks,
Jacob
Hi,
Might have to add a role separator field? or use $wp_roles->role_objects.
i.e. If you have a custom role labeled Contract Manager and named contract_manager or even contractmanager, get_editable_roles() always return the label instead of role-name, this will cause get_users(array('role' => 'Contract Manager')) to not return the users for the role, as get_users actually fetches based on the role-name, not label.
I keep getting the following error:
FATAL ERROR: CANNOT USE OBJECT OF TYPE STDCLASS AS ARRAY IN
I added this to my functions.php file
` function get_author() {
$postid = get_the_ID();
$authors = get_field('author', $postid);
if($authors) {
foreach($authors as $author) {
echo 'By '. $author['user_email'] .' on ';
}
}
}`
and this in my page template:
echo get_author();
Any suggestions?
Hello,
I am using your user field code to add a new field to the Advanced Custom Fields Wordpress plugin. Works great in the WP admin interface, but I am also trying to use the new front-end form feature in ACF, where you can include ACF forms in page templates. When I display a form containing the custom user field, I receive the following error:
Fatal error: Call to undefined function get_editable_roles() in /nfs/c07/h02/mnt/99917/domains/alert.washingtonandlee.net/html/wp-content/themes/wlualert/fields/users-field.php on line 182
Can you help me to properly define the get_editable_roles() function when used inside the loop?
Thanks,
Eric Owsley
I would like to change the formatting from the multi-select box to a scrollable list of checkboxes (just like the default scrollable boxes to choose pages to add to a menu in the admin).
This will make things much safer to hand over to a client - with multiSelect, if a user accidentally clicks another name without holding down the CTRL button, all the previously selected options are undone. I know that a user could just refresh the page without saving, but the option to have this in a checkbox format would be greatly appreciated.
Thanks!
I am having a problem with the user field add on, where if you save via the backend post section it saves into the db as a user id, where as if you use the the update_field within a repeater, it saves as an array with all sorts of user info.
I get this error message:
Fatal error: Cannot redeclare class Users_field in ---[path]----users-field.php on line 434
Got this problem to show all users in my panel in admin, when "Filter by role" is set to "-All-" or when I select them all. In my panel, the administrators will show up.
What I have done is:
In my functions.php I have this code
if(function_exists('register_field'))
{
register_field('Users_field', dirname(File) . '/admin/acf_addon/users_field.php');
}
When I have my Custom Field I add a field and choose 'User' as 'Field Type'.
Mark all and save.
And when I look at the posts panel only administrators will show up.
How ever I try to change the 'Filter by Role'-option only the ones that are Administrators will be displayed and selectable.
I've tried modifying the script to turn it into an activatable WordPress plugin but keep getting errors.
Do you have plans on releasing a vs. that I can simply activate as a plugin?
Hi
I'm trying to add custom fields to my users - phone, cell and the like. This works fine in the back end, the form elements appear and seem to save, but I can't seem to get the values back in a template.
If I use
<?php
foreach($values as $value)
{
echo '<pre >';
print_r($value);
echo '</pre >';
}
?>
I can only see the native user fields.
Array
(
[ID] => 3
[user_firstname] =>
[user_lastname] =>
[nickname] =>
[user_nicename] =>
[display_name] =>
[user_email] =>
[user_url] =>
[user_registered] => 2012-08-21 21:53:18
[user_description] => This is my description field.
)
(values redacted)
I am having a bit of an issue trying to get this to work on my site.
I added the following code
'$author = get_field('author');
if ($author) {
echo 'By '. $author["display_name"] .' on ';
}'
But I get the following error:
Fatal error: Cannot use object of type WP_User as array
Anything I am doing wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.