• Resolved Harsh Goyal

    (@harshgoyaa)


    Hi team,

    i wanted to know if the below is possible.

    i will be creating a website using Ultimate Member – User Profile, User Registration, Login & Membership Plugin, and use the registration page to get all the details that i want. Now depending on the membership plan the client uses, i would be giving them access to the details of other people. for instance i would like to hide the contact details of all clients and depending the membership plan, i would allow them to see the contact details of other users.

    Example

    GOLD- 30 users
    silver – 15 users
    now if someone is gold member, he/ she is allowed to see the contact details(hidden data) of only 30 users, which he/she can chose from the list of users in all users. after 30 seeing the hidden/ contact details of 30 users, the member has to take the member ship again.
    we are assuming the content which is hidden is the contact details and will be available based on the membership plan.

    i know its bit complicated, but if you get it please let know. i am ready to buy the paid version

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

    (@champsupertramp)

    Hi @harshgoyaa

    UM has a WooCommerce extension that changes the user role when you purchase a product. For more details, you can contact us via our website: https://ultimatemember.com/contact/sales

    It’s a bit complicated with the user’s visibility to show specific users selected from the All users. Are you referring to the WP Admin > Users? How’s the gold member going to select the 30 users? For contact details, UM has field visibility/privacy settings. You can display the field to profile owner only or specific user roles.

    Regards,

    Thread Starter Harsh Goyal

    (@harshgoyaa)

    Hi @champsupertramp, thank you for replying.

    You can display the field to profile owner only or specific user roles.- > this helps. but i wanted to know, i want the user to be able to view the contact details of only 30 other users(any other users.) once he/she has seen the details of any 30 users, he/she has to take membership again. and also i not talking about the admin area dashboard. i am talking about the front end it self.

    i wanted to use the plugin to generate income. like a dating website. so a user can get details of 30 any other users (GOLD membership),if he wants to get more contact details of other user he has to subscribe again.

    hope you can help me.

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @harshgoyaa

    So there’s a required function to record the viewed users of the Gold Member? Or if the Gold Member has viewed 30 users, the membership will expire and no longer be able to view those 30 users that just viewed?

    Regards,

    Thread Starter Harsh Goyal

    (@harshgoyaa)

    Hi @champsupertramp
    yes,

    if the Gold Member has viewed 30 users, the membership will expire and no longer be able to view any users other than the 30 users which they selected. take membership again to get the details of other users (so 30 + new 30).

    So there’s a required function to record the viewed users of the Gold Member?
    at-least we have to record the Count so that, membership can taken multiple times

    • This reply was modified 2 years, 10 months ago by Harsh Goyal.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @harshgoyaa

    This requires further customization. I would create a new database table to save the selected users and then you can count all the saved users to limit viewing profiles/pages and display a notice on pages if the member has reached 30 users and provide a link to the WooCommerce product to purchase another Gold membership product.

    Regards,

    Thread Starter Harsh Goyal

    (@harshgoyaa)

    hi @champsupertramp Thanks a lot,

    To be clear, I would like to sum up.

    My website is like a dating website were people have to take membership (gold/ silver) depending on which they allowed to view limited no of other users(gold 60 and silver 20). so every time they view someone’s profile the count reduces based on the package and once the count is exhausted, the person has to retake member ship.

    2 Membership plans
    GOLD- 60 user profiles
    Silver – 20 user profiles

    @champsupertramp Thanks a lot this helps me out so much ??

    will wait for your reply ??

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @harshgoyaa

    When that Gold/Silver member visits a profile twice, will it deduct 2 from his/her limit?

    Regards,

    Thread Starter Harsh Goyal

    (@harshgoyaa)

    hi, @champsupertramp

    When that Gold/Silver member visits a profile twice, will it deduct 2 from his/her limit?->
    no, he/she can visit the same profile “N” times

    Thanks and Regards

    • This reply was modified 2 years, 10 months ago by Harsh Goyal.
    Thread Starter Harsh Goyal

    (@harshgoyaa)

    Hi @champsupertramp

    Also I forgot to mention the users who take membership are given a role of “Subscriber”.
    so the above change should effect only the users with role “Subscriber”. other role users should be having the above function.

    and Final thing, i wanted to know if it is possible to display some of users info (which is collected during registration example:- hobbies, height etc) over here as show in black in Screen shot

    https://drive.google.com/file/d/13LXI7FKAS6f7V0OyH525OMjhiEq4pwzy/view?usp=sharing

    Thanks and Regards

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @harshgoyaa

    yeah, I would create a database table to save the visited profile.

    Here’s the table structure for the custom table:
    Table structure( table name: wp_custom_visited_profiles:
    – id ( BIGINT – auto increment )
    – user_id ( INT )
    – visited_user_id (INT )
    – visited_date ( datetime )

    In WooCommerce product settings, add an attribute named um_view_profile_limit with the viewing limit number e.g. 30

    So when a user visits a profile, I will use the following code snippet to check if the currently logged-in user visits a profile. It will redirect the user to a custom page /reached-limit/ when the user has reached the limit number set in the product settings. Please note that you can have multiple purchased products. The code below will sum up the limit from different products for the currently logged-in user:

    add_action("template_redirect","um_custom_visit_profile", 99999 );
    function um_custom_visit_profile(){
        if( ! class_exists("UM") ) return;
       
        if( ! um_is_myprofile() && um_is_core_page("user") ){
    
            global $wpdb;
            $visiting_user_id = um_get_requested_user();
            $user_id = get_current_user_id();
           
            // GET USER ORDERS (COMPLETED + PROCESSING)
            $customer_orders = get_posts( array(
                'numberposts' => -1,
                'meta_key'    => '_customer_user',
                'meta_value'  => $user_id,
                'post_type'   => wc_get_order_types(),
                'post_status' => array_keys( wc_get_is_paid_statuses() ),
            ) );
           
           
            if ( ! $customer_orders ) return;
            
            // Get all user's purchased products and sum all the limit
            foreach ( $customer_orders as $customer_order ) {
                $order = wc_get_order( $customer_order->ID );
                $items = $order->get_items();
                foreach ( $items as $item ) {
                    $product_id = $item->get_product_id();
                    $p = new WC_Product( $product_id );  // create an object of WC_Product class
                    $limit = (int)$p->get_attribute( 'um_view_profile_limit' );  // call get_attribute method
                    update_user_meta( $user_id, "um_view_profile_limit", $limit );
                }
            }
    
           $has_row = $wpdb->get_row( $wpdb->prepare(
               "SELECT * FROM {$wpdb->prefix}custom_visited_profiles WHERE user_id = %d  AND visiting_user_id = %d", $user_id, $visiting_user_id ) 
            );
    
            $total_visited = (int) get_user_meta( $user_id, "um_total_visited_profiles", true );
            
            if( ! $has_row ){ // if user hasn't visited this profile, add the viewing profile in the currently logged-in user's record
                $table = $wpdb->prefix.'custom_visited_profiles';
                $data = array('user_id' => $user_id, 'visiting_user_id' => $visiting_user_id );
                $wpdb->insert( $table, $data );
                $results = $wpdb->get_results( $wpdb->prepare("SELECT * FROM {$wpdb->prefix}custom_visited_profiles WHERE user_id = %d ", $user_id ) );
                update_user_meta( $user_id, "um_total_visited_profiles", count( $results ) );
            }
    
            $total_limit = (int) get_user_meta( $user_id, "um_view_profile_limit", true );
           
            if( $total_visited >= $total_limit && ! $has_row ){ // If the user rechead the viewing limit, redirect them to a custom page
                wp_redirect("/reached-limit"); exit;
            }
        }
    }

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @harshgoyaa

    You can show the user details in the tagline. Just go to WP Admin > Ultimate Member > Member directories > Edit a directory > see “Profile Card” > see “Choose field(s) to display in tagline”.

    Regards,

    Thread Starter Harsh Goyal

    (@harshgoyaa)

    Hi @champsupertramp

    You can show the user details in the tagline. Just go to WP Admin > Ultimate Member > Member directories > Edit a directory > see “Profile Card” > see “Choose field(s) to display in tagline”. => on point, perfect ??

    In WooCommerce product settings, add an attribute named um_view_profile_limit with the viewing limit number e.g. 30
    um_view_profile_limit=30 => right?

    So when a user visits a profile, I will use the following code snippet to check if the currently logged-in user visits a profile. It will redirect the user to a custom page /reached-limit/ when the user has reached the limit number set in the product settings. Please note that you can have multiple purchased products. The code below will sum up the limit from different products for the currently logged-in user:

    => here i was not clear, what i have to do.

    adding a attribute for woocommerce i understood, the second part i am not clear

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @harshgoyaa

    You can add the code I’ve provided above to your theme/child-theme’s functions.php file or use the Code Snippet to run the code. You will need to create a custom WordPress table named wp_custom_visited_profiles with the following column names and data types:

    – id ( BIGINT – auto increment )
    – user_id ( INT )
    – visited_user_id (INT )
    – visited_date ( datetime )

    Regards,

    Thread Starter Harsh Goyal

    (@harshgoyaa)

    @champsupertramp

    okay got it,

    will try it out and get back to you ??

    Thanks a lot in advance

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    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 by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

Viewing 15 replies - 1 through 15 (of 33 total)
  • The topic ‘Restrict content for certain number of users’ is closed to new replies.