• Resolved angusryall

    (@angusryall)


    Hi, I have recently upgraded to 2.1.11 (from the old version, 2.0.56). Previously I had a function in members-grid.php which checked for content in the ‘description’ field, and didn’t display the member card if this field was empty. Now members-grid has changed to include a load of js, my function no longer works.

    This was my previous function, starting at line 19:

    ===============================

    um_fetch_user( $member ); ?>

    <?php /*added by angus to hide new signups with no description */ ?>

    <?php
    $description = get_user_meta( um_user( ‘ID’ ), ‘description’, true );

    if ( ! empty( $description ) ) { ?>

    ==============================

    Now I have this, but it doesn’t work:

    ================================

    <# if ( data.length > 0 ) { #>

    <# _.each( data, function( user, key, list ) { #>

    <?php /*added by Angus to check if there is anything in ‘description’*/
    $user_id = um_user(‘ID’);
    um_fetch_user( $user_id );
    $description = um_user(‘description’);
    if ( ! empty( $description ) ) { /*end added by Angus*/ ?>

    ============================

    Can you tell me what needs to change here? or point me to any documentation about this?

    Regards
    Angus Ryall

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @angusryall

    Why not use a filter hook to modify the query?

    Here’s a code snippet to prevent users without description from showing in the member directory:

    
    add_filter("um_prepare_user_query_args", function( $query_args, $directory_data){
    
        $query_args['meta_query']['relation'] = 'AND';
    
        $query_args['meta_query'][ ] = array(
            'key'       => 'description',
            'compare'   => '!=',
            'value'     => '',
        );
      
    
        return $query_args;
    
    }, 99999, 2 );
    

    Regards,

    Thread Starter angusryall

    (@angusryall)

    Thanks Champ, does that go in functions.php?

    Thread Starter angusryall

    (@angusryall)

    Don’t worry, put it in functions.php, worked straight off. Respect!

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @angusryall

    Thanks for letting us know. I am closing this thread now.

    Regards,

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

The topic ‘checking meta in users grid’ is closed to new replies.