Support » Plugins » HidePost Plugin’s link protection issue/customization?

  • I am just wondering for those of you more skilled than I am, regarding this plugin:

    If I enable Link Protection only (without using Hidepost’s main feature to protect whole posts), I want to show the actual title/text for the link in question but without it being linked (ie, tags removed), or it being linked to the url I specify in $hidepost_link_text setting instead, how would I have to change the functions inside hidepost.php in order to accomplish this (and I’ve tried a few things, only resulting in errors and such)?

    Keep in mind here is the default behaviour below (it replaces all links with $hidepost_link_text text instead of what I’m trying to do – replacing the value of href with my own link and or extra code, etc):

    function hidepost_replace_link($content) {
    	global $current_user, $user_ID, $hidepost_link_text, $hidepost_link_text_hide, $m_id;
    	preg_match_all('#\<a(.*?)\>(.*?)\</a\>#sie', $content, $matches);  //Find all the link
    	if ($user_ID == ''){//If not logged in
    		if ($hidepost_link_text_hide != 1) return $hidepost_link_text; else return '';
    	} else {return $matches[0][$m_id];} //Or return the content if user can see
    function hidepost_filter_post($content) {
        global $m_id, $hidepost_hide_link, $hidepost_hide_content;
    	//Protect the link
    	if ($hidepost_hide_link == 1) {
    	$m_id = -1;//Magic ^.^
    	$content = preg_replace('#\<a(.*?)\>(.*?)\</a\>#sie','hidepost_replace_link($content)',$content);
    	//Protect content
    	if ($hidepost_hide_content == 1) {
    	$m_id = -1;
    	$content = preg_replace('#\[hidepost(.*?)\](.*?)\[/hidepost\]#sie','hidepost_replace_hide($content)',$content);
    	return $content;


Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey, try to replace return $hidepost_link_text with
    return $matches[1][$m_id];

    I haven’t tried it but I think it working.
    Good to include in the next version 🙂

    Ahhh, nice try… almost had it.

    I replaced it with this instead

    return $matches[2][$m_id] . $hidepost_link_text;

    and that shows the actual text with links stripped out of it + my custom sign up link text.

    Some degree of customization of this feature would really be appreciated in the next version, like the ability to display the link text (like above, with $matches[2][$m_id]) and then define a custom link we want that to be linked to instead, such as the %login% or %register% link… or anything else.

    Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘HidePost Plugin’s link protection issue/customization?’ is closed to new replies.