it is possibile to create some attributes user can use only in a paid package and not in the free?
This related post may help :
i mean a way to create some attributes to add only in the paid listings ( example: link to website, social link…) not in the free listings
someone can help me??
I 've just shown you a solution, but you don’t want to consider it.
It works wonders for me.
Ciao.
i don’t know how to do…anyway should i past the above code you provided on functions.php of the theme or should i create a new plugin in /wp-content/plugins/ ?
function add_custom_body_class_for_package($classes) {
// Ottieni l'utente corrente
$current_user = wp_get_current_user();
if ($current_user->ID) {
$package = get_user_meta($current_user->ID, '_transient_hp_models/user_listing_package/version', true);
if (!empty($package)) {
$classes[] = sanitize_title($package);
} else {
$classes[] = 'no-package';
}
}
return $classes;
}
add_filter('body_class', 'add_custom_body_class_for_package');
if data are in “usermeta” is better to use get_user_meta()
and not $wpdb
→ because faster
what do you think ?
Always welcome to improve what’s provided
anyway i added your code in the snippet but nothing happened of what I’m looking for
If your site is online, shoot the url. I’ll check it.
[edit]
Anyway it won’t work perfectly in your case, as, by design, you choose the package AFTER you create the listing.
Works well to display/hide elements though, depending on package level.
Mi spiace !
[/edit]
here the packages as i desire but i don’t understand why if in a package we can choose when the listing expires , why we can’t choose other attributes like the link to the website, an image or what ever ?
First by using the script above, it would automatically add the current page name to the body
tag :
Let’s take the example of the direct link, and let’s it’s a text field which name is “direct_link”. You want to enable the vendor to fill in this link.
You could do that to hide by default (in the form)
input[name="direct_link"] {
display:none;
}
And show it if the vendor has the right package:
body.my-paid-package input[name="direct_link"] {
display:block;
}
Problem is you only hide the text field, not the rest, like label, description… or the parent DIV still show as they have no class attached to it.
However, you could use a jQuery code snippet, to go up the DOM tree, and hide the parent DIV, hence label, description… by using something like :
jQuery(document).ready(function($) {
$('input[name="direct_link"]').parent().hide();
});
Likewise, you would also need some javascript to prevent other users from seeing a blank (empty) value, if any, with jQuery.
It’s not perfect, it’s a lot of fuss, just a workaround.
And as I said, for the user having a package already set, so not for the first listing, unfortunately.
Maybe consider using the membership add-on, but as I don’t have it, I cannot guarantee it would work any better in your case (i.e. as a vendor).
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.