WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Contributors Page - How to not display some authors (8 posts)

  1. Nymso
    Member
    Posted 2 years ago #

    Hi there,

    I am having real trouble trying to filter out a few authors from my contributors page.
    The code I have been trying to mod using $excluded was in the functions.php file and listed as follows:

    function periodic_contributors() {
    	global $wpdb;
    
    $authors = $wpdb->get_results("
    		SELECT  ID, display_name
    		FROM wp_users
    		INNER JOIN wp_usermeta
    		ON wp_users.ID  = wp_usermeta.user_id
    			WHERE wp_usermeta.meta_key = 'wp_capabilities'
    		AND (wp_usermeta.meta_value
    			LIKE '%admin%'
    			OR wp_usermeta.meta_value
    			LIKE '%contributor%'
    			OR wp_usermeta.meta_value
    			LIKE '%editor%'
    			OR wp_usermeta.meta_value
    			LIKE '%author%')
    		ORDER BY display_name
    		");

    Please help!

    Thank you

  2. Nymso
    Member
    Posted 2 years ago #

    Any ideas anyone?

  3. keesiemeijer
    moderator
    Posted 2 years ago #

    So you want to exclude some users from the results periodic_contributors(); returns?

    Can you paste and submit the full function periodic_contributors() into a pastebin.com and post the link to it here? see the Forum Rules for posting code and using the pastebin.

  4. Nymso
    Member
    Posted 2 years ago #

    Hi keesiemeijer,

    Opps newbie here who didn't read the forum rules, thanks for pointing that out to me.

    Here is the full function: http://pastebin.com/c6dqfjji

    Thanks for taking the time to look into my situation - cheers

  5. vtxyzzy
    Member
    Posted 2 years ago #

    I have a site where I want paid Contributors to have different privileges from non-paid Contributors. I have used the CIMY User Extra Fields plugin to add an extra field to the User Profile.

    I set the field so that only an Admin can edit it. Then, when someone pays the dues, I set the field to true.

    The plugin provides functions to get the value of the field so it can be checked.

  6. Nymso
    Member
    Posted 2 years ago #

    Thanks vtxyzzy, I tried that plugin but I could not see how to hide or not show a selected number of profiles.

    Any more ideas?

    I still need to exclude some users from the results periodic_contributors(); returns.

    Thanks

  7. vtxyzzy
    Member
    Posted 2 years ago #

    That plugin will do what you asked. Try these steps:

    1. Add a CIMY field named IS_CONTRIBUTOR.
    2. Give it a Label of 'Show as Contributor'.
    3. Give it a value of 'NO'.
    4. Select 'checkbox' in the Type dropdown.
    5. Select 'Can be modified only by admin' in the 'Can be modified' dropdown.
    6. Check 'Show the field in Users Extended section'.
    7. Click 'Update field #1' on the right.
    8. Go to Admin->Users->'Users Extended' to set each person to the correct status.
    9. Modify your periodic_contributor() function as shown below.

    Change this:

    foreach($authors as $author) {
       echo "<li>";

    to this:

    foreach($authors as $author) {
       $value = get_cimyFieldValue($author->ID, 'IS_CONTRIBUTOR');
       if ($value != 'YES') continue;
       echo "<li>";
  8. Nymso
    Member
    Posted 2 years ago #

    Thank you vtxyzzy!!

    Your instructions did the trick! You are a smart cookie! Thanks again!

    Cheers

    Nymso

Topic Closed

This topic has been closed to new replies.

About this Topic