• Resolved johnmactack12

    (@johnmactack12)


    Hello

    I wanted to ask if it possible for user profile pages to be disabled only for the comment sections of blog posts?
    An example of what I mean is that a user should be able to visit their own profile page and see the posts they have or comments they have made but when they make a comment on a public blogpost, visitors should not be able to have a link to their page.

    I am familiar with the umroles that allow users not to click on other roles profile page but the problem with that is that u can still copy the link to their profilepage and be able to view it on another browser

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

    (@champsupertramp)

    Hi @johnmactack12

    Do you want to redirect users to a custom page when accessing/visiting a user profile that is not their own?

    Regards,

    Thread Starter johnmactack12

    (@johnmactack12)

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @johnmactack12

    Please try adding the following code snippet to your theme/child-theme’s functions.php file or use the code snippet to run the code:

    add_action("template_redirect","um_110321_redirect_to_custom_page");
    function um_110321_redirect_to_custom_page(){
    
        if( ! um_is_myprofile() && ! current_user_can("manage_options") && um_is_core_page("user") ){
            wp_redirect("/");
        }
    }

    The above code will redirect the user to homepage when visiting a profile that’s not their own.

    Regards,

    Thread Starter johnmactack12

    (@johnmactack12)

    Thank you for the reply, is there anyway i can change this snippet so when a user clicks on another users profile link it just stays on the same page or refreshes the same page?

    Kind regards

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @johnmactack12

    You can try this code snippet:

    add_action("template_redirect","um_110321_redirect_to_custom_page");
    function um_110321_redirect_to_custom_page(){
    
        if( ! um_is_myprofile() && ! current_user_can("manage_options") && um_is_core_page("user") ){
            if( isset( $_SERVER['HTTP_REFERER'] ) ){
               wp_redirect( $_SERVER['HTTP_REFERER'] );
            }else{
               wp_redirect("/");
            }
        }
    }

    Regards,

    • This reply was modified 4 years, 6 months ago by Champ Camba.
    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 6 replies - 1 through 6 (of 6 total)

The topic ‘User Profile Links’ is closed to new replies.