lewismcarey / User-Field-ACF-Add-on

User Field Add on for Advanced Custom Fields
40 stars 19 forks source link

The add on is broken with latest ACF 3.5.6.3 and WP 3.5.x #16

Closed unfulvio closed 11 years ago

unfulvio commented 11 years ago

I get this error message:

Fatal error: Cannot redeclare class Users_field in ---[path]----users-field.php on line 434

blowsie commented 11 years ago

Works fine for me in Version 3.5.7.2 and WP 3.5

unfulvio commented 11 years ago

I've upgraded to ACF latest, but the problem is still there, I've inspected my code, I'm not including this addon twice, neither I have other addons conflicting or other plugins interacting with ACF installed... Also checked the file for any whitespace issue, it doesn't seem to be that.

unfulvio commented 11 years ago

This looks like a similar issue on a different ACF addon: https://github.com/GCX/acf-taxonomy-field/issues/43

shaunbent commented 11 years ago

@Mompracem could you confirm what version of PHP you are running? I have set this up on my testing server running WP 3.5, ACF Version 3.5.7.2 on PHP version 5.3.5 and have not been able to recreate this issue.

unfulvio commented 11 years ago

I was using 5.3 and now updated to 5.4 same issue

I also updated MySQL to 5.5 the other day, no changes

shaunbent commented 11 years ago

Not an ideal solution but have you tired wrapping your register_field in an if ( class_exists ) ?

unfulvio commented 11 years ago

it was wrapped in if ( function_exists ) as per instructions

doesn't make a difference with class

I tried also with if ( !class_exists( 'Users_field' ) ) among other combinations, but also in this case throws the same error - I assume you wanted to check whether a class 'Users_field was declared before registering the new field, but apparently it wasn't since even doing so throws the same error...

unfulvio commented 11 years ago

fixed it

I had to hack the addon file and wrapping it with

if( !class_exists( 'Users_field' ) && class_exists( 'acf_Field' ) )

I was wrapping the register_field function in functions.php to load the addon - that one is fine to wrap with a condition to check if register_field function exists, but the class exist conditional has to be inside users_field.php