*

Vettalo

  • ***
  • 59 posts
public profile url driving me crazy
« on: September 22, 2021, 12:58:58 PM »
Hello guys,
how can i get the public profile url by user name not id
www.example.com/user/alex

i have url by id number

www.example.com/user/93

in demo i can see that when you click view user profile it shows url by name
Regards.

*

Vettalo

  • ***
  • 59 posts
Re: public profile url driving me crazy
« Reply #1 on: September 23, 2021, 02:53:47 AM »
asking a question and answering it lol,
to get public profile by s_name simply go to includes/osclass/helpers/hUser.php
and look for:

    function osc_user_public_profile_url($id = null) {
        if($id==null) {
            $id = osc_user_id();
        }
        if ($id != '') {
            if ( osc_rewrite_enabled() ) {
                $user = User::newInstance()->findByPrimaryKey($id);
                $path = osc_base_url().osc_get_preference('rewrite_user_profile')."/".$user['s_username'];
            } else {
                $path = sprintf(osc_base_url(true) . '?page=user&action=pub_profile&id=%d', $id);
            }
        } else {
            $path = '';
        }
        return $path;
    }

and replace s_username with s_name and your done.

code will look like

    function osc_user_public_profile_url($id = null) {
        if($id==null) {
            $id = osc_user_id();
        }
        if ($id != '') {
            if ( osc_rewrite_enabled() ) {
                $user = User::newInstance()->findByPrimaryKey($id);
                $path = osc_base_url().osc_get_preference('rewrite_user_profile')."/".$user['s_name'];
            } else {
                $path = sprintf(osc_base_url(true) . '?page=user&action=pub_profile&id=%d', $id);
            }
        } else {
            $path = '';
        }
        return $path;
    }
Regards.

*

Vettalo

  • ***
  • 59 posts
Re: public profile url driving me crazy
« Reply #2 on: September 23, 2021, 03:20:58 AM »
asking a question and answering it lol,
to get public profile by s_name simply go to includes/osclass/helpers/hUser.php
and look for:

    function osc_user_public_profile_url($id = null) {
        if($id==null) {
            $id = osc_user_id();
        }
        if ($id != '') {
            if ( osc_rewrite_enabled() ) {
                $user = User::newInstance()->findByPrimaryKey($id);
                $path = osc_base_url().osc_get_preference('rewrite_user_profile')."/".$user['s_username'];
            } else {
                $path = sprintf(osc_base_url(true) . '?page=user&action=pub_profile&id=%d', $id);
            }
        } else {
            $path = '';
        }
        return $path;
    }

and replace s_username with s_name and your done.

code will look like

    function osc_user_public_profile_url($id = null) {
        if($id==null) {
            $id = osc_user_id();
        }
        if ($id != '') {
            if ( osc_rewrite_enabled() ) {
                $user = User::newInstance()->findByPrimaryKey($id);
                $path = osc_base_url().osc_get_preference('rewrite_user_profile')."/".$user['s_name'];
            } else {
                $path = sprintf(osc_base_url(true) . '?page=user&action=pub_profile&id=%d', $id);
            }
        } else {
            $path = '';
        }
        return $path;
    }
Regards.

it gives error not found
i will look after it later.
Regards.

*

MB Themes

Re: public profile url driving me crazy
« Reply #3 on: September 24, 2021, 01:14:47 PM »
User ID is default value for "user name" field, so it actually does not use user ID, but user name.
Having different value in user name could do the trick!
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Vettalo

  • ***
  • 59 posts
Re: public profile url driving me crazy
« Reply #4 on: September 26, 2021, 12:46:19 AM »
User ID is default value for "user name" field, so it actually does not use user ID, but user name.
Having different value in user name could do the trick!

its not hard to get it but i have changed my mind.
i will give advantage to users to choose username in their profile, this way will have to pick his name or his company name.
thats better than changing userid with their names.
i already done it by adding this code in user profile.

                 <div class="row">
       <label for="s_username"><?php _e('User name', 'beta'); ?></label>
                 <div class="input-box"><?php UserForm::username_text($user); ?> <div id="available"></div></div>
                 </div>
Regards.

*

MB Themes

Re: public profile url driving me crazy
« Reply #5 on: September 27, 2021, 02:24:24 PM »
@Vettalo
Just verify if it is checking user name uniqueness as well ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Vettalo

  • ***
  • 59 posts
Re: public profile url driving me crazy
« Reply #6 on: September 28, 2021, 01:28:32 PM »
@Vettalo
Just verify if it is checking user name uniqueness as well ;)
What do u mean?
This code is not working?
<div class="row">

       <label for="s_username"><?php _e('User name', 'beta'); ?></label>
                 <div class="input-box"><?php UserForm::username_text($user); ?> <div id="available"></div></div>
                 </div>

*

Vettalo

  • ***
  • 59 posts
Re: public profile url driving me crazy
« Reply #7 on: September 28, 2021, 01:34:18 PM »
It is working perfectly but not inside the profile form
It has unique form as action username update.
One question!
Does beta theme has pagination in public profile i cant see it?
Regards.

*

MB Themes

Re: public profile url driving me crazy
« Reply #8 on: September 28, 2021, 03:22:14 PM »
@Vettalo
I do not thin Beta theme has pagination there, as osclass did not support it here (until you brought completely custom code & solution there)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Vettalo

  • ***
  • 59 posts
Re: public profile url driving me crazy
« Reply #9 on: September 29, 2021, 01:24:51 AM »
@Vettalo
I do not thin Beta theme has pagination there, as osclass did not support it here (until you brought completely custom code & solution there)
Yes you are right osclass missing many functions i see you added photo profile in your osclass version updates and that fumction was very important, to be honest you have made good job i have checked all the functions you added in it and all them are effective and was missed before except the tinymce i see this function should be disabled for users i suppose all at least should be enabled only for sellers (company).
Best regards.

*

MB Themes

Re: public profile url driving me crazy
« Reply #10 on: September 29, 2021, 07:56:53 AM »
@Vettalo
Thank you, you can disable TinyMCE in Oc-admin > Listings > Settings.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots