• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

Implemented spaces in author name breaks author page

Gracie

Dogs Times Writer
The only option in XenWord is to turn on / off access to the user panel.

Screen Shot 2016-03-26 at 6.49.47 PM.png
 

Gracie

Dogs Times Writer
The next option is to simply go into the database and edit the user_nicename.

Open phpmyadmin
click on WordPress database for site
click on wp_users
click on Browse
double-click on space for user_nicename
change to "customer-2" style nicename
save
open another browser tab and try /author/customer-2
 

LPH

Flight Director
Flight Instructor

Good job @Gracie - this is definitely WordPress at its finest :)

I purchased the theme, downloaded it, installed it and noticed that the link to the author page is different based on the post versus author page. For example, the space is on the loop for main page but the hyphen is present on the author page itself.

Since you also own the theme, can you ask the developer how to get the link to always show with the user_nicename?

According to a quick search for user_nicename, the getParsedObject appears to pull it. I'm just not sure when they use that method and when it is not used.

PHP:
public function getParsedObject() {

   if(!$this->posts) {
      return array();
   }

   foreach($this->posts as $key => $val) {
      $ret[$key]['post-id'] = $val->ID;
      $ret[$key]['post-slug'] = $val->post_name;
      $ret[$key]['post-url'] = get_permalink($val->ID);
      $ret[$key]['date-published'] = date(get_option('date_format'), strtotime($val->post_date));
      $ret[$key]['date-modified'] = date(get_option('date_format'), strtotime($val->post_modified));
      $ret[$key]['thumbnail'] = $this->getPostThumb($val->ID);
      $ret[$key]['thumbnail'] = !empty($ret[$key]['thumbnail']) ? $ret[$key]['thumbnail'] : LS_ROOT_URL . '/static/img/blank.gif';
      $ret[$key]['image'] = '<img src="'.$ret[$key]['thumbnail'].'" alt="">';
      $ret[$key]['image-url'] = $ret[$key]['thumbnail'];
      $ret[$key]['title'] = htmlspecialchars(__($val->post_title), ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE);
      $ret[$key]['content'] = wp_strip_all_tags(__($val->post_content));
      $ret[$key]['excerpt'] = $this->getExcerpt();
      $ret[$key]['author'] = get_userdata($val->post_author)->user_nicename;
      $ret[$key]['author-id'] = $val->post_author;
      $ret[$key]['categories'] = $this->getCategoryList($val);
      $ret[$key]['tags'] = $this->getTagList($val);
      $ret[$key]['comments'] = $val->comment_count;
   }

   return $ret;
}
 

Gracie

Dogs Times Writer

dethfire

Baby Penguin
XenWord Professional
In the meantime, is there a way to do a redirect? I have some links in XF to their WP profiles and that will still break.
 

LPH

Flight Director
Flight Instructor
Yes. I was actually working on a change to the author link filter that is currently in XenWord.

Open class-xenword-author-link.php and replace the xenword_author_link() with the following:

PHP:
        $xenword_author_user_nicename = get_the_author_meta( 'user_nicename' );
        $xf_author_link =  get_site_url() . '/author/';
        $xenword_author_link = $xf_author_link . str_replace(' ', '-', $xenword_author_user_nicename );

        return $xenword_author_link;

This was working locally - but - your site is much more complex. Let's see what happens.

PS. I had to restart the server because caching wasn't showing the change. You will definitely want to clear any caching.
 

LPH

Flight Director
Flight Instructor
hmmm edited and restarted web server with no luck

Wait. Huh? Oh - my bad. I didn't tell remind you to turn on the option in the XenWord Settings Panel? Or did you ?

Turn on the Author redirect. In 3.0.3.01 there are now two sliders. One will redirect to XenForo and the other does a replace of the space to hyphen.
 

dethfire

Baby Penguin
XenWord Professional
That worked! I'm not how that logically makes sense to turn on that setting though :)
 

dethfire

Baby Penguin
XenWord Professional
What links and is this a different issue?
It's not a XW issue, but I have links in user postbit areas that link to their author page. This is generated simply by adding their username to the base author URL. So I need to interrupt and fix the url for those with a space.
 
Top