WordPress.org

Ready to get started?Download WordPress

Forums

Facebook Connect & author pages (3 posts)

  1. dchase
    Member
    Posted 5 years ago #

    Ok, so I am trying to set up Facebook Connect (the sociable version not the WP version) but instead of having the 'members' profiles go to the default Facebook connect profile I want them to go to the WordPress author page. I have managed to change all of the links to that they go to ?author=XX instead of ?fbconnect=myhome etc..

    However, I also want to use permalinks. So, pointing to ?author-XX works fine when the author id is of an author that was created not using Facebook connect. When you go to ?author=XX for a FB Connect user it redirects a permalink structure that looks like this: /author/FirstnameLastname. However, the page comes up as a 404 error.

    Now, Facebook connect sets the nicename as a FB_FACEBOOKID and what so the author page should be a /author/FB_FACEBOOKID but that also returns a 404 error.

    The really odd part is, if I turn off the permalink structure, and go to ?author-XX for a FB Connect user, the author page comes up just fine.
    Any ideas?

  2. Adam Hobson
    Member
    Posted 5 years ago #

    Ok, so I had the exact same problem. After combing through the plugin, I can't figure out what is going wrong. I'm not even sure it's the plugin itself, because the problem still occurs when the plugin is deactivated. The problem must be with how the Facebook Connect plugin creates the user accounts, but after comparing Facebook accounts to normal accounts in the database, I just didn't see what was different.

    However, I made this hand little hack that basically tells the 404 page to become the author page when it's given "author_name" as a query parameter and then the query is reset with the proper author_id. So just plug the following in your functions file or turn it into a plugin:

    if (!function_exists('show_facebook_authors')) {
    
    	function show_facebook_authors($template) {
    		global $wp_query;
    		if( !is_author() && get_query_var('author_name') ) {
    			// Grab author data
    			$author = get_userdatabylogin( get_query_var('author_name') );
    
    			// Rebuild Query
    			$wp_query = null;
    			$wp_query = new WP_Query();
    			$wp_query->query('author=' . $author->ID . ''); 
    
    			// Return 'Overwrite default 404 template...';
    			return get_author_template();
    		}
    		return $template;
    	}
    
    	add_filter('404_template', 'show_facebook_authors');
    }
  3. djjose
    Member
    Posted 4 years ago #

    For those of you having this problem with the Sociable plugin. I've hacked the heck out of this plugin for a project and ran into the same issue. the problem lies with the fact that autor permalinks use user_nicename for the URL generation. Apparently it can't have spaces, or at least can't be explicitly told to have spaces as the plugin does. Open fbConnectLogic.php, line 126 and change the line from:
    $user_data['user_nicename'] = $usersinfo["first_name"]." ".$usersinfo["last_name"];
    to
    $user_data['user_nicename'] = $usersinfo["first_name"]."-".$usersinfo["last_name"];

    You'll notice I added a hyphen "-" instead of a space " ". This does the trick. For any users you have registered already you'll have to manually go into phpMyAdmin and change the fields for them (just add in hyphens). For those of you having this problem with the FB-Connect problem I'd wager to say it's the same problem. You'll just have to find the line of code in the plugin similar to above that inputs to the database and make sure it isn't explicitly putting spaces.

    Hope this helps.

Topic Closed

This topic has been closed to new replies.

About this Topic