Hello @regnalf
Please try using this filter:
apply_filters( 'um_prepare_user_query_args', $query_args, $directory_data );
What does this filter have to do if i want a frontend filter that a user can choose from?
As far i’ve figured it out is i need the
add_filter( 'um_members_directory_filter_fields', ...
to register a new meta field. (Hook wont fire)
Set the type of the field with
add_filter( 'um_members_directory_filter_types', ...
(Hook works)
Declare the options to choose from with
add_filter( 'um_search_fields', ...
(Did fire, but have no registered field, cause first hook not work)
Do finaly the filtering:
add_filter( 'um_query_args_{{$field_name}}__filter_meta', ...
(Could not trigger because field ist not registered)
Am i miss something?
I think i found the issue! You call the
add_filter( 'plugins_loaded', array( &$this, 'init_variables' ), 99999 );
in class-member-directory, that loads before my function.php could fire!
After change it to:
add_filter( 'after_setup_theme', array( &$this, 'init_variables' ), 99999 );
the hook works!!! So please change your filter!
Hi @regnalf
Thanks for letting us know how you’ve resolved the issue. Feel free to re-open this thread by changing the topic status to “Not Resolved” if you are still having issues so we can take a look at it.
Regards,
Yes i solved the issue, but i changed the source code from the plugin!!!!
If you don’t change it too, i have to fix it by every update!!
So please fix:
add_filter( 'plugins_loaded', array( &$this, 'init_variables' ), 99999 );
to
add_filter( 'after_setup_theme', array( &$this, 'init_variables' ), 99999 );
Hi @regnalf
Why not remove the filter and then attach yours? Here’s a code snippet:
if( class_exists("UM") ){
remove_filter( 'plugins_loaded', array( UM()->member_directory(), 'init_variables' ), 99999 );
add_filter( 'after_setup_theme', array( UM()->member_directory(), 'init_variables' ), 99999 );
}
Regards,
Yes, that’s working, but don’t you think this should be a solution for all who needs this? Because, all other hooks to create a custom filter are working without modify your ‘init_variables’ filter.
Or is there another reason why you need it to be on ‘plugins_loaded’? This could prevent further support calls, for other who fall into this!
Hi @regnalf
Just letting you know that I’ve created an issue on our public Github repository:
https://github.com/ultimatemember/ultimatemember/issues/1002