WordPress.org

Ready to get started?Download WordPress

Forums

Stop authors of syndicated posts being added as users (5 posts)

  1. modifiedcontent
    Member
    Posted 1 year ago #

    Is there a way to stop WP from adding authors from syndicated posts, from feedwordpress or similar, as users to the system?

    Or is there a way to filter these "users" out? Perhaps by role?

    They are messing up my attempts to create a member network.

  2. Adding users to ... what? You mean showing authors in RSS feeds?

  3. modifiedcontent
    Member
    Posted 1 year ago #

    > Adding users to ... what? You mean showing authors in RSS feeds?

    To wp-users in the database.

    Not from RSS feeds of course, but from syndicated posts that are added to WP's own post system, by plugins like FeedWordPress - I think there are others that do the same and other ways this type of ghost members can be created.

    Is there a function (?) in WP that adds post authors to the database? Something that checks if an author is in wp-users and add him/her if he/she is not?

    Anything I can do a search on, so I can try to come up with a workaround? Maybe a filter (?) to stop FeedWordPress doing add_user or whatever it is?

    Or a catch-all solution to make sure that users are NEVER added, except via registration or administrator.

    Don't know where to start with this...

  4. radgeek
    Member
    Posted 1 year ago #

    Hi there,

    Well, if you are using FeedWordPress, here is a quick way to do what it sounds like you are looking to do.

    First, you'll need to add some code to the functions.php file in your theme. Are you able to do this? (If not, let me know and I can offer some alternative options.)

    In your functions.php, add the following code. Replace your own preferred values for the items in ALL CAPS.


    add_filter('syndicated_item_author', 'my_syndicated_post_author', 20, 2);
    function my_syndicated_post_author ($author, $post) {
    $author = array(
    'name' => 'JOE DOKES',
    'email' => 'JOE@DOKES.COM',
    'url' => 'HTTP://JOEDOKES.COM/',
    );
    return $author;
    }

    If you want to make sure that this is correctly matched to an existing user in your system, the best thing to match up would be the email address in 'email'.

    Note that doing this will make it so that incoming posts are stripped of any information about who authored them on the original source. This may not be a problem, if this information is already included in the content of those posts, or if it will be obvious from contextual factors who wrote it. But you may want to filter the content of posts so that some information about the author will be preserved in the post content even if it is not recorded in the wp_users table. To do this, you can add something like the following to your functions.php file, right around where you added the above author filter. (Feel free to change out the HTML in the single quotes to whatever message you want.)


    add_filter('syndicated_item_content', 'my_syndicated_post_byline', 20, 2);
    function my_syndicated_post_byline ($content, $post) {
    $a = $post->author();
    $content = sprintf('<p class="byline">By %s.</p>', $a['name']) . $content;
    return $content;
    }

    Let me know if this helps fix your problem.

  5. modifiedcontent
    Member
    Posted 1 year ago #

    Thank you so much radgeek!

    I haven't tested it yet, but this looks all pretty straightforward and exactly what I need. All the clues I needed to get started.

    It should even be possible to replace JOE DOKES with some kind of variable for the owner of the blog/site where the syndicated post appears. If I can find enough time over the holidays to figure that out I'll post my solutions here.

Topic Closed

This topic has been closed to new replies.

About this Topic