• I want to add a custom meta filter in the membership directory.

    But unfortunately the hook ‘um_members_directory_filter_fields’, is not been called!

    add_filter( 'um_members_directory_filter_fields', 'my_um_members_directory_filter_fields', 10, 1 );
    function my_um_members_directory_filter_fields ( $filter_fields )
    {
    	$filter_fields['custom_meta'] = 'Custom Meta Field Description';
    	return $filter_fields;
    }

    The ‘um_members_directory_filter_types’ did fire

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @regnalf

    Please try using this filter:

    apply_filters( 'um_prepare_user_query_args', $query_args, $directory_data );

    Thread Starter regnalf

    (@regnalf)

    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!

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    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,

    Thread Starter regnalf

    (@regnalf)

    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 );

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    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,

    Thread Starter regnalf

    (@regnalf)

    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!

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @regnalf

    Just letting you know that I’ve created an issue on our public Github repository:
    https://github.com/ultimatemember/ultimatemember/issues/1002

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Add new custom meta field for filtering’ is closed to new replies.