• Resolved patrikhoermann

    (@patrikhoermann)


    I have set up a Affiliate-System where every User gets his own Affiliate Link:

    webside.com/register/?ref=1
    (As example – The Affiliate-Link of User with the User-ID 1.)

    When User 2 signs up with the Affiliate-Link of User 1, that Value gets stored through a hidden field in the Signup-Page to a Meta-Value.
    So User 2 will have the Meta_value -> Recommender: 1 (ID of his Recommender)

    Now I want to create a directory where the user with the ID 1 can only see the members that signed up with his specific Affiliate Link.
    Therefore I have to get the Users ID and preselect all the Members with that specific ID.

    Is there a way to get the User-ID and have that as a default-preselection Value assigned with the corresponding “Recommender” – Meta_value

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

    (@champsupertramp)

    Hi @patrikhoermann

    Unfortunately, this requires customisation on your end.

    You can use the wp.hooks to modify the parameters in the member directory request. Use this javascript to pass data via ajax with filter hook um_member_directory_filter_request:

    const { addFilter } = wp.hooks;
    addFilter(
    "um_member_directory_filter_request",
    "content",
    extendMemberDirectoryRequest
    );
    
    function extendMemberDirectoryRequest( query ){
    console.log( query ); // display current query in browser log
    return query;
    }

    and then catch data in the ajax filter:
    um_prepare_user_query_args

    Regards,

    Thread Starter patrikhoermann

    (@patrikhoermann)

    I have never worked with wordpress hooks before.

    I thought about some code in the functions.php that runs only on the specific page-id ( page id from the page where I insert the shortcode for the custom-directory-form) that gets the User-ID and filter the directory before showing it in the frontend.

    Is there some documentation I can read to get my custom-directory running?

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @patrikhoermann

    You can try this code snippet below, but you will need to modify the query to match your situation.

    <?php
    /**
     * Include specific IDs to the Member Directory Query
    */
    add_filter("um_prepare_user_query_args","um_custom_prepare_user_query_args", 10, 2 );
    
    function um_custom_prepare_user_query_args( $query_args, $directory_data ){
       
      $target_directory_id = 123;
    
      if( $target_directory_id == $directory_data['form_id'] ){
         $query_args['include'] = array( 1, 2,3,8,9,10 ); // includes IDs of your affiliates here.
      } 
    
      return $query_args;
    }
    ?>

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @patrikhoermann

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. ??

    Regards,

    Thread Starter patrikhoermann

    (@patrikhoermann)

    I editet your snippet:

    
    
     add_filter("um_prepare_user_query_args","um_custom_prepare_user_query_args", 10, 2 );
    
    function um_custom_prepare_user_query_args( $query_args, $directory_data ){
       
        $target_directory_id = 8177;
        
    
     if( $target_directory_id == $directory_data['form_id'] ){
    
          
    
        global $wpdb;
        $user_id = get_current_user_id(); 
    
        $downlines = $wpdb->get_col( 
    	"
    	SELECT      user_id
    	FROM        abwyz_usermeta
    	WHERE       meta_key = 'glbl_rwf_attracted_by'
    	            AND meta_value = $user_id
    	"
    );
    
        //$query_args['include'] = $downlines; // includes IDs of your affiliates here.
        $query_args['include'] = $downlines; // includes IDs of your affiliates here.
      } 
    
      return $query_args;
    }
    

    Is it possible for a normal user in the frontend to delete the request and get the full member-list?
    Like change something with the Inspector in the scripts?

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @patrikhoermann

    Could you please provide more details? I’m confused with the delete request.
    Is it possible for a normal user in the frontend to delete the request and get the full member-list?

    Regards,

    Thread Starter patrikhoermann

    (@patrikhoermann)

    With this Code I filter the member List to only show a specific group of users.

    Maybe some Users will try it with the inspector and edit the code from the displayed Memberlist to get all the members and not only the filterd group of users.

    My question – Is it possible for a normal member to bypass this filter somehow and see the whole member-list?

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @patrikhoermann

    You can add a restriction for those who can only search the users with specific roles. With that approach, those logged in users won’t be able to retrieve other users with the restricted roles.

    Regards,

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Member Directory preselectet Members by Meta-ID’ is closed to new replies.