Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a multi-author Wordpress site which reads different rss feeds and posts them to my page. I was wondering if it is possible to make a code that would provide an opportunity to registered user choice of which authors/sources to follow. There is already a few plugins that allow users to subscribe or 'follow' an author with email notifications (Example). But what I'm looking for is how to allow a user to select which feeds they want to read and this plugin would show only those feeds on my website.

I have little knowledge of php but none from Wordpress really. Where should I start developing it? It needs to remember each user's follows so it has to be saved database for what i know.

share|improve this question
Do you mean feeds? Or do you just want to hide/show content depending on the users' preferences? Feeds are just urls which they can add to reader, thus subscribing them to that feed. – Stephen Harris Aug 13 '12 at 13:18
Yes i mean feeds. FWP makes them into normal posts but what i'm requesting is exactly that user can filter on/off (show/hide) authors depending on what they want to read. So when they log in they have ability to control content in each users' homepage. – kissatkoiria Aug 14 '12 at 7:13
Example Like that but with authors that user can select from user-preferences – kissatkoiria Aug 16 '12 at 12:51

1 Answer

function select_authors_fields( $user ) {
$authors = get_users();
$user_tags = get_the_author_meta( 'select_authors', $user->ID );
?>
<table class="form-table">
    <tr>
        <th>My interests:</th>
        <td>
    <?php
    if ( count( $authors ) ) {
        foreach ($authors as $author) {
             if (user_can($author->ID, 'publish_posts')) { ?>
        <p><label for="select_authors_<?php echo esc_attr( $author->ID); ?>">
            <input
                id="select_authors_<?php echo esc_attr( $author->ID); ?>"
                name="select_authors[<?php echo esc_attr( get_the_author_meta('display_name', $author->ID) ); ?>]"
                type="checkbox"
                value="<?php echo esc_attr( get_the_author_meta('ID', $author->ID) ); ?>"
                <?php if ( in_array( get_the_author_meta('ID', $author->ID), $user_tags ) ) echo ' checked="checked"'; ?> />
            <?php echo esc_html(get_the_author_meta('display_name', $author->ID)); ?>
        </label></p><?php
             }
         }
    } ?>
        </td>
    </tr>
</table>
<?php
    }

add_action( 'show_user_profile', 'select_authors_fields' ); add_action( 'edit_user_profile', 'select_authors_fields' );

// store authors
function select_authors_fields_save( $user_id ) {
    if ( !current_user_can( 'edit_user', $user_id ) )
        return false;
    update_user_meta( $user_id, 'select_authors', $_POST['select_authors'] );
}
add_action( 'personal_options_update', 'select_authors_fields_save' );
add_action( 'edit_user_profile_update', 'select_authors_fields_save' );

This ones prints authors in user preferences with checkboxes. Now i need to make post_query depending selections. Any clues?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.