WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Feed Key] adding key to ALL feeds (4 posts)

  1. thinky72
    Member
    Posted 5 years ago #

    hi hami,
    you are doing great work with your plugins. i mentioned lately when using members-only and feed-key, that the feed-key is not implemented in all rss-feeds that are offered ... actually it would be useful, when the feed-key is automaticalli added to ALL or maybe to selectable categories or elements (eg. the status-bar ... )

  2. nemoprincess
    Member
    Posted 5 years ago #

    This is my code to retrieve feedkey from wordpress db for logged user:

    <a href="
    <?php
    	global $current_user;
    	$feedvalue = $wpdb->get_var("SELECT meta_value FROM $wpdb->usermeta WHERE user_id='$current_user->ID' AND meta_key='feed_key'");
    
    	echo (get_bloginfo('url').("?feed=rss2&feedkey=").($feedvalue));?>">Post RSS Feed</a>

    If it can be helpful

  3. woody3k
    Member
    Posted 5 years ago #

    Hi,

    Had an idea on another method for adding the feedkey to any feed links for a currently logged in user. This code could be added to the feed-key.php plugin:

    function feedkey_feed_link($feed_link)
    {
    	global $current_user;
    
    	$feedkey = get_usermeta($current_user->ID,'feed_key');
    	$permalink_structure = get_option(permalink_structure);
    	//Check if Permalinks are being used
    
    	//If feed key is defined for this user
    	if (is_user_logged_in() && !empty($feedkey))
    	{
    		empty($permalink_structure) ? $feedjoin = '&feedkey=' : $feedjoin = '?feedkey=';
    		$output = $feed_link.$feedjoin.$feedkey;
    	}
    	else
    		$output = $feed_link;
    
    	return $output;
    }
    
    add_action('feed_link', 'feedkey_feed_link', 10, 1);

    Hooking this action means that the rss link is updated whenever it is added to a page. It works with/without permalinks, and for the basic feed query strings - eg. 'rss2_url' or 'comments_rss2_url', but I haven't tested it against more complex rss query strings.

  4. thinky72
    Member
    Posted 4 years ago #

    hi woody3k

    intresting hack - but i didnĀ“t figure out, in wich files i have to add your code ... can you give us a hint??

    regards
    thinky

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags