• Resolved dkance

    (@dkance)


    Hi,

    I would like to have Role A users only access contact info of User Role B Profile data if they purchase her service.

    How do I go about hiding the contact info pre pay and make it available post pay (Woocommerce)?

    Any hints on how to solve this problem in a simple way?

    Is there a way to manage data accesibility by location (page)?

    Thanks.

    Regards.

    Diego

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

    (@champsupertramp)

    Hi @dkance

    You can try the following code snippets:

    add_action("init","um_100921_has_bought_product");
    function um_100921_has_bought_product(){
        if( function_exists("wc_customer_bought_product" ) ){
            $product_id = 131;
            if ( ! wc_customer_bought_product( um_user("user_email"), get_current_user_id(), $product_id ) ) {
                
                add_filter("um_first_name_form_show_field","__return_empty_string");
                add_filter("um_last_name_form_show_field","__return_empty_string");
            }
        }
    }

    The above code will hide the first name and last name when the currently logged-in user still hasn’t purchased the product ID 131.

    Regards,

    Thread Starter dkance

    (@dkance)

    Hi @champsupertramp,

    Thank you so much for the code.

    It produced a fatal error. Not sure why, but I inmediately removed it from Snippets.

    What might be wrong?

    Regards,

    Diego

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @dkance

    What was the fatal error?

    Is WooCommerce active on your site?

    Regards,

    Thread Starter dkance

    (@dkance)

    Hi @champsupertramp,

    Thank you for getting back to me.

    I am sharing the Fatal Error message

    Error Type E_PARSE in line 1 of file code-snippets eval()’d code. Error Message: syntax error, unexpected ‘&’

    I hope it helps.

    Regards,

    Diego

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @dkance

    Did you copy the exact code? You have an extra & in the code that you need to remove when you add the code to your site.

    add_action("init","um_100921_has_bought_product");
    function um_100921_has_bought_product(){
        if( function_exists("wc_customer_bought_product" ) ){
            $product_id = 131;
            if ( ! wc_customer_bought_product( um_user("user_email"), get_current_user_id(), $product_id ) ) {
                
                add_filter("um_first_name_form_show_field","__return_empty_string");
                add_filter("um_last_name_form_show_field","__return_empty_string");
            }
        }
    }

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @dkance
    ..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 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Displaying Profile hiding fields for certain roles’ is closed to new replies.