• WP-FacebookConnect users apparently can only leave comments. Can they be WP “Authors” so that they can make new posts?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author ahupp

    (@ahupp)

    An existing administrator can change the user’s role in the admin console to anything they want, including administrator or author.

    -Adam

    I use wordpress for online publishing for a public facing website. It would be tedious to do this for every single new user. Can it be done initially via some sort of code so it’s not required to do it for every single user?

    You could use a plug-in like role-scoper to modify the default permissions of subscribers so that they’re able to create new posts. Then, no role changes would be necessary, and you could keep actual administrators separate from facebook-connect users in your user administration, as well.

    Go to the flugin and edit it. In the “common.php” file go down to the PHP function “fbc_insert_user()” and change the role to “author”.

    In the end it should look like this.

    function fbc_userinfo_keys() {
      return array('name',
                   'first_name',
                   'last_name',
                   'profile_url');
    }
    
    function fbc_insert_user($fbuid) {
    
      $userinfo = fbc_anon_api_client()->users_getInfo(array($fbuid),
                                                       fbc_userinfo_keys());
    
      if ($userinfo === null) {
        error_log('wp-fbconnect: empty query result for user ' . $fbuid);
      }
    
      $userinfo = $userinfo[0];
    
      $fbusername = 'fb' . $fbuid;
      if (username_exists($fbusername)) {
        return FBC_ERROR_USERNAME_EXISTS;
      }
    
      $userdata = fbc_userinfo_to_wp_user($userinfo);
      $userdata += array(
        'user_pass' => wp_generate_password(),
    
        /*
          WP3.0 requires an unique email address for new accounts.  We might
          not have one, so give it a unique and identifiably fake address.
        */
        'user_email' => $fbusername.'@wp-fbconnect.fake',
        'user_login' => $fbusername,
        /*
          In the event this blog is configured to setup new users as
          admins, don't apply that to fbconnect users.
         */
        'role' => 'author'
      );
    
      $wpuid = wp_insert_user($userdata);
      // $wpuid might be an instance of WP_Error
      if($wpuid && is_integer($wpuid)) {
        update_usermeta($wpuid, 'fbuid', "$fbuid");
      }
    
      return $wpuid;
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can WP-FacebookConnect users be WP "Authors"?’ is closed to new replies.