Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore General Questions › Displaying User Level Specific Messages Without Protected Content Box?
- This topic has 11 replies, 2 voices, and was last updated 13 years, 4 months ago by Zain.
-
AuthorPosts
-
June 28, 2011 at 10:06 pm #3680ZainParticipant
Hi,
I’m just wondering if there’s a way of displaying messages to users without using the [emember_protected] shortcodes? The reason is that these shortcodes produce tables with an image saying “Hidden content is forbidden for this membership level.” (which really messes up the flow of the page when there’s lots). At the moment, I’m having to find specific Post IDs and then “hide” these boxes using CSS. Even then, there’s these miscellaneous <p> tags appearing before the tables.
It would be much easier (and cleaner) to display a messages targetted to specific user levels.
Scenario
Free users see a list like this:
- Page 1
- Page 2
- Page 5
Whereas Paid users get to see a list like this:
- Page 1
- Page 2
- Page 3
- Page 4
- Page 5
If the existing [emember_protected] shortcodes are used, then the Protection Boxes will appear in between this list that hides Pages 3&4. Ideally, a shortcode that just specifies “if this user is of X level(s), allow them to see this message”.
Also, is it possible to have negated shortcodes. E.g. [emember_protected not_id=1] – which would display content to members of any level except 1. Otherwise, the [emember_protected for=2-3-4] could get *really* long. Much easier to just exclude the ones you don’t want from a long list of “do wants”.
Having looked through the files and code, I notice there’s quite a lot of new features that are coming but just not documented. Is this something that is coming soon?
Cheers,
Zain
June 29, 2011 at 3:13 am #33764amin007ParticipantMost people like to show the “content is protected” message. You can however make it so it doesn’t show anything.
If you are using the following section protection shortcode
[emember_protected for=1-2-3]
Then open wp_eMember1.php and search for the following:
return wp_emember_format_message ('<b>'. EMEMBER_HIDDEN_CONTENT_MESSAGE. '<br/>'.EMEMBER_PLEASE.' <a href=" '.$account_upgrade_url .'" target=_blank>'.EMEMBER_RENEW.'</a> '.EMEMBER_YOUR_ACCOUNT.'</b>');
Once you find it you can change it to the following:
return "";
You can also customize the message that gets displayed to the users:
No, there is no shortcode for the “NOT” condition. This is something we would like to add in the future.
July 4, 2011 at 8:18 pm #33765ZainParticipantHi Amin,
Thanks for the reply, although wouldn’t changing wp_eMember1.php also mean that, effectively, NO content box appears? What I’m suggesting is that *both* situations are useful.
Update on the workaround: it didn’t work! But seeing as you pointed me in the right direction, I managed to fix it (solution below). The line that needed to be changed to
return "";
was actually:return wp_emember_format_message($replacement);
(found at the end of the emember_protected_handler() function).
Protection Scenarios
I’m not sure if you get what I mean by having this functionality. It simply provides a little more flexibility (I think WishList has this, btw). Here are some examples:
There are times as an admin that you’d like users to know that content is protected (e.g. let basic members know they have to upgrade to a higher level to gain access to restricted content). This is how eMember normally behaves.
The other situation is more for when you want to display different items depending on the membership role (e.g. same content on the page but display more options just for users of X level). Saves on having to create duplicate content just to display a few lines for different users.
My Workaround
What I did was to take your suggestion and created a new shortcode:
add_shortcode("emember_protected_hidden","emember_protected_hidden_handler");
(just after the normal emember_protected shortcode!)Then, I copied the existing emember_protected_handler() function and created a new version called “emember_protected_hidden_handler()”.
After that, it was just a case of replacing:
return wp_emember_format_message($replacement);
with:
return "";
Job done!
What this does is to provide the flexibility of both situations, so now I can display different messages depending on what’s required.
I’m currently using this solution on my new site where, if the user hits the Login page and is already logged in, it displays a different message to if when they are logged out and politely asks them to log in.
Taking The Idea One Step Further…
Just wondering… but does this emember_protected shortcode actually stop any content being rendered to the screen? If so, then in theory, having this “emember_protected_hidden” version could also (theoretically) be used to add javascript files and maybe even flash content just for users of specific levels.
For example – Bronze members being shown a video of the benefits of Silver membership, while Silver members are shown a video of Gold benefits.
Get the picture?
July 5, 2011 at 2:49 am #33766amin007ParticipantGood idea. I will actually modify the existing shortcode so you can specify an extra parameter in the shortcode that lets you customize if you want to display the “Restricted” message or not.
July 5, 2011 at 7:23 am #33767ZainParticipantThat’s an even better idea! Durr… As an ex-Developer, I should’ve thought of that but I’m in a rush to get a Members area up (so not really thinking through a “proper” solution).
Right now, I’m looking to have a Dashboard that displays 1 set of content for Free users, then additional information for Paid members.
Hat’s off – well done – on thinking up of a better solution that makes the code cleaner and less cluttered. Keep up the great work Amin
Nice one!
July 8, 2011 at 6:56 pm #33768ZainParticipantHey Amin,
Just discovered that WishList *DON’T* have this feature built yet. Also, according to a customer who submitted a similar request, their Dev team said there were no immediate plans to implement this. Get this… according to the guy, the WL Dev team said “it can’t be done at the moment” maybe a future release!
This basically means that you have a head start on a feature that people actually want. Plus, the bonus of knowing that *in theory* this can work with a few amendments.
I’ll send you a link to the thread if you want to read it! Just give me a shout…
Personally, I just want to see *SOMEONE* build this feature. It’s extremely powerful for creating a very targeted marketing message to very specifically grouped customers!
Anyway… looks like the race is on. Good job I used both plugins. Just thought you’d like to know.
July 9, 2011 at 1:48 am #33769amin007ParticipantOkay added another parameter to the section protection shortcode. You can optionally add
"do_not_show_restricted_msg=1"
to the section protection shortcode like the following to turn off the protected content message box:[emember_protected for=2 do_not_show_restricted_msg=1]
The content here will be protected for membership level 2. This section will be totally hidden to anonymous users or members who do not have access to this level (no content protected message will appear for this section).
[/emember_protected]
July 9, 2011 at 4:55 pm #33770ZainParticipantAmin,
You’re a complete star!
You do realise this feature is the equivalent to “List Segmentation” in Email Marketing?! This now means Admins can do very specific offer codes aimed at customers. With a few more tweaks it can be extremely powerful.
Oh, just to let you know… I’ve been posting up the same idea at WishList’s Public Forum… but there’s been no reply. People like the idea and can see the benefits. Have a look at the discussion here:
http://wishlistproducts.zendesk.com/entries/326745-hiding-text-produced-by-private-tags
You’ll see that there are several scenarios where this type of shortcode feature will be extremely useful. If you incorporate a “Date/Time” feature, it gets mind-blowing. Imagine what kind of timed offers you could do with this “hidden text” and your WP eStore coupons!
Like I said… I just want *someone* to build this so I can get my site running.
Great job on beating WishList to it! Question is, do you think some of the other “attributes” could be incorporated?
I’m about to do a blog post on this and will add a link to this page.
Well done on this feature. Please do remember to update the shortcode manual – I find that invaluable. Again, that’s something that WishList doesn’t seem to have a quick shortcode list… so great work on that!
Please feel free to implement any of my ideas – all I’d ask is you let me know so I can start using them!!!
Cheers,
Zain
July 9, 2011 at 11:48 pm #33771ZainParticipantHi Amin,
Thanks for updating the plugin. I’m currently testing the shortcode and it does work and doesn’t display the message.
From testing, one suggestion that I’d like to make is that ideally the “hide message” shortcodes should really be a different tag. This is so that “Shortcode Nesting” can be done.
Consider the following example:
`[emember_protected scope=verified_users_only]
Hi User, Welcome to the Members Area.
[emember_protected member_id=1 do_not_show_restricted_msg=1] As a FREE member you get nothing[/emember_protected]
[emember_protected member_id=2 do_not_show_restricted_msg=1] As a Basic member, here’s some stuff[/emember_protected]
[/emember_protected]`
As you can, what we’re trying to achieve here is that only “Verified/Logged in” users can see the message AND each messages will only display to either the FREE or Basic member, depending on their level.
The problem though, is that because they all use the same Shortcode, after the first message, the
[/emember_protected]
end tag will terminate the string (and so reveal the rest). Basically, the nesting is wrong.Ideally, another shortcode would be better: e.g.
[emember_protected scope=verified_users_only]
[emember_hidden member_id=1] Free Members get nowt [/emember_hidden]
[emember_hidden member_id=2] Your Basic Member bonus items [/emember_hidden]
[/emember_protected]As you can see, the nesting is correct because the shortcodes have different names. Also, there’s no need to add the long
" do_not_show_restricted_msg=1"
string (that’s quite a bit to type, btw – “hide_msg=1” would be shorted and probably easier to remember!).The easiest way to do this is simply like I did previously – it’s essentially another shortcode but with the logic slightly tweaked.
Anyway, thought you should know this feedback. This will be one of the ways that people will tend to use these “hidden” message shortcodes.
Cheers,
Zain
July 19, 2011 at 7:46 am #33772ZainParticipantHi Amin,
Just to let you know that WishList are looking into this feature at the moment as they can see the potential of having powerful functionality like this. At the moment, you have a head start, as they have a roadmap and this functionality is basically “feature creep”.
I was also wondering if you’ve managed to do anything with the “nesting” issue? From using this feature, this is the 1 thing which keeps breaking the protection as I’m testing. Yes, it is possible to stop the protection then start again… although a “nested” shortcode is much simpler to use (and causes less headaches – I’m technical and so, if I find problems using it… well, you can imagine what non-technical users would run in to!).
Also, another small suggestion: do the attribute names have to be so long? Wouldn’t
"hide_msg=1"
or even"hide=1"
be easier to type and equally as understandable as"do_not_show_restricted_msg=1"
. Seriously, it does take a lot of typing to do the underscores each time…Thanks in advance,
Zain
July 20, 2011 at 4:01 am #33773amin007ParticipantI don’t have a proper solution for the nesting thing that you mentioned. I don’t like the idea of introducing another copy of the shortcode that does the same thing just for nesting. Someone else will need a double nesting down the path (which will need another set of shortcode) so it doesn’t solve the problem really.
The attribute name is long and descriptive on purpose. Even though I like short names, from an average customer’s point of view a long description name leaves no room for confusion (some of my older products with short attribute name thought me this).
July 23, 2011 at 6:41 am #33774ZainParticipantHi Amin,
In terms of double nesting, I’m not sure that situation would happen. Here’s the logic:
Non Logged in Users
If the
[emember_protected scope=not_logged_in_users_only]
is used, then because a user isn’t logged in, it’s not possible to display a member specific message anyway. Double nesting can’t happen here.Logged in Users
If an Admin uses the
[emember_protected member_id=1]
– then it doesn’t matter. It’s not possible to introduce another shortcode in this mode as it’s only for members of this ID. Double nesting cannot happen here.The nested problem happens when an Admin uses the
[emember_protected scope=verified_users_only]
shortcode. At this point, the Admin isn’t sure which type of Member is logged in but still wants to display a member specific message.In theory, Admins could use the
for=1-3-5
scope and introduce a double nesting issue, however the whole point of this shortcode is that it’s used for member specific messages (double nesting is actually redundant). To overcome this, an Admin just needs to use the shortcode to display specific messages for the member ID.Code Bloat
As for code bloat, the way round it is to create the shortcode functions which call the rendering function. i.e. The core functionality (displaying the output) would be in a separate function – when the shortcode is called it simply calls the function to return what needs to be displayed. This reduces code bloat by re-using functions (and making the code elegant).
Shortcode Attribute Names
In terms of short attribute names, personally, I think good documentation usually helps with confused customers. The shortcode PDF you provide is an excellent resource – it explains what the shortcodes are and what it does.
I have a feeling that this document is probably very underused (although it would help resolve a lot of issues). Simply providing the documentation for quick reference when a user purchases the plugin could help to reduce the amount of questions as it does cover a lot of what you can do. Yes, this does assume that people read it (which they often don’t!) so a bit of copy to urge the customer to read it helps too.
At the moment, I find I have to trawl the site to find the documentation to find the answers – clear documentation helps overcome common problems. An FAQ is useful too.
Hope that helps.
Cheers,
Zain
-
AuthorPosts
- You must be logged in to reply to this topic.