Pro Sites Suggestion

Pro Sites Plugin should have the option to limit “the number of blogs a user can create” for different levels.

  • James Morris
    • WordPress Enthusiast

    Hello silvio

    I hope you are well today!

    This is a great suggestion! I see this suggestion has been added to our Features & Feedback forum. Our Team will take a look at this and consider it for future versions of the plugin. Please keep in mind that features are added on a popularity basis. The more members asking for it, the more likely it will make production.

    Thanks again for the feedback! :slight_smile:

    Best regards,

    James Morris

  • silvio
    • Design Lord, Child of Thor

    this is a feature asked for years and year , we just need to see the forums , I don’t understand why we don’t have this feature because ALL owners of a multisite platform want to limit an user to create blogs , that’s a no brain here !

  • James Morris
    • WordPress Enthusiast

    Hello silvio

    There’s already currently the ability to limit signups to a single blog/subsite, or allow multiple blog signups in Pro Sites. What we’re missing at this point is setting a limit to a specific number of signups. So, this would definitely be a useful feature for sure. But please note it could still easily be circumvented by a determined enough user.

    That being said, doing some digging around and it seems our SLS Team has already come up with a potential workaround while this feature is being considered for future releases.

    Please see the following comment and subsequent comments for more information. https://premium.wpmudev.org/forums/topic/pro-sites-limit-sites-per-user-per-level#post-1237421

    I hope this helps in your situation. :slight_smile:

    Best regards,

    James Morris

  • Ash
    • WordPress Hacker

    Hello silvio

    Do you have any live site link that we can access? The link you sent is from your local site on your computer.

    So, if you have any live site, please enable support access and we will take a look. If needed, we will even discuss with the same SLS developer for help :slight_smile:

    Have a nice day!

    Cheers,

    Ash

  • Lindeni Mahlalela
    • Recruit

    Hello silvio

    I hope you are doing great today, I am sorry for the delayed response from our side and sorry for any inconvenience caused.

    I have double checked the code provided on the other thread and verified its behaviour, basically all it does is take the limits set in the settings screen and check if the user has not reached those limits, if the limits have been reached then it simply displays an error message instead of the pricing table which means the user will not be allowed to even select a level on the pricing table if they have reached the limit.

    After implementing the code as suggested above forum URL, pricing table not displaying getting message "Sorry", on this URL http://localhost/wpmu/pro-site/?action=new_blog

    The "Sorry" came from the code provided and it will be printed if the limit for creating blogs has been reached. I saw that there was a small mistake on the code which caused the code not to append additional information to the sorry to let the user know why they have been denied to create a blog.

    So I have modified the code so that it displays the relevant error message to the user if they have reached the limit. You will find the code attached in this post, just extract and upload the "limitblogs.php" file to replace the one in: wp-content/plugins/pro-sites/pro-sites-files/modules/limitblogs.php. Once that is done you can set the limits on the page "ProSites > Settings > Limit Blogs and Levels" and here is how it works:

    Number of blogs per user – is the total number of blogs a user can have in the Network across all levels

    Blogs per Level – is the limit for each level, this means if you set a number on this like 3 then the user will be allowed to create 3 blogs per level and the some of these will be further limited by the "Number of blogs per user" set above.

    Limit of free blogs – is the number of free blogs a user can have in the network. This is not limited by the limit per level, but will be limited by the number of blogs per user.

    Once you have set this up, you should test to see how it works. You should see messages like the following if a limit has been reached.

    The way it is set up right now, is that it will display only the message on the page instead of the pricing table. If you prefer to show it below or above the pricing table instead of of replacing it entirely then you should consider editing the file to comment out the line that has the 'template_redirect' hook so it looks like this:

    //add_action( 'template_redirect', array( &$this, 'set_blog_creation_limit' ) );

    and then remove the forward slashes on the line at the bottonm of the __construct function to make them look like this:

    add_action('signup_header', array($this, 'set_blog_creation_limit') );
    add_action('signup_blogform', array(&$this, 'set_blog_creation_limit') );

    One of these two lines will do, so consider commenting the other one out while testing the other to see the difference. If you choose these two hooks you might have to do some additional coding to make sure the users are not able to signup because this code will only display the error message without any restrictions.

    If you wish to set a different limit for each level, you will have to add in the logic to achieve that but the settings part has been taken care of already, you just have to comment out the last part of the table at the bottom of the 'settings()' function.

    I hope this helps, please let us know if you need any further assistance. Please note that the provided code is not a final solution for this you still have to improve it to achieve exactly what you need to achieve.

    Have a nice day.

    Lindeni

  • Lindeni Mahlalela
    • Recruit

    Hello silvio

    Please check my last post above, it seems we were both posting almost at the same time. The code has been modified to give more meaningful error messages. It should work as it is but as it stands you can only set one limit that will apply to all levels but there is already a foundation from which you can develop if you need to control the limits separately for each level.

    Please let us know if you need any further assistance.

    Have a nice day.

    Lindeni

  • silvio
    • Design Lord, Child of Thor

    Hi Lindeni,

    I used plugin after implementing the code as you discuss above thread, but it's not working properly every time its shows, "Sorry you have reached blog limit".

    I have attached the current setting as I set from the backend, please just fix this for multiple levels, that means the number of blogs will set on the basis of per level.

  • Lindeni Mahlalela
    • Recruit

    Hello silvio

    I hope you are doing great today. I am sorry for the delayed response from our side, things have been real busy but I haven't forgotten about you.

    I have modified the limitblogs.php file previous shared so that it accommodates various levels as set on your Pro Sites dashboard. Please find the attached limitblogs.zip file, download, extract and upload the limitblogs.php file to your website in the location:

    pro-sites/pro-sites-files/modules/limitblogs.php

    Everything else stays the same as in the previous fix. Once you have done that you should notice the settings page now includes the Pro Sites Levels and now you can set a limit for each of them separately. It should look like this:

    How this will work is that on the Pro Sites pricing table, if someone chooses a level it will automatically submit the level and other data to check for if the currently logged in user has reached a limit for the selected level, if they have reached the limit it will hide the form and show the error message like so:

    All this happens immediately after the user selects a level, if they switch a level it will check that level and display the error message. It leaves the form as is if they there is no limit reached.

    Please note that while this works, it may not be the perfect solution for you, in which case you should consider changing the code yourself or consulting our Jobs Board and hire a professional developer as this solution already exceeds the scope of this support forum. Please note that this is not a final solution and is not yet scheduled for inclusion in the next release so make sure to backup before updating Pro Sites and reapply this fix as required.

    I hope this helps. Please let us know if you have any queries or concerns.

    Have a nice day.

    Lindeni

  • silvio
    • Design Lord, Child of Thor

    Hello Lindeni,

    I integrated code as we discussed above.

    I was set the number of blog per level.

    As I register “Premium” level that have 5 blogs set from the backend,

    I registered one blog first time, but second time its again asking for payment, I think limits not working there.

    Please, check once into the system as i integrated.

  • Lindeni Mahlalela
    • Recruit

    Hi silvio

    I hope you are doing great today. Thanks for your feedback and for the additional questions.

    …but second time its again asking for payment, I think limits not working there.

    Yes this is expected and its basically the main functionality of Pro Sites. Each new blog will have to be paid for. One user can have multiple paid blogs on the same level.

    …I think limits not working there.

    The limits work to restrict the user from registering a certain number of blogs of the same level, so as you have set the number to 5 for the “Premium” level it means any user can not have more than 5 blogs the Premium level so they will be allowed to register 5 blogs but once they attempt to register the 6th blog it won’t allow them, it will show the message saying “Sorry you have reached blog limit” with the appropriate description for the limit reached.

    The solution on this thread does not allow them to pay once for each level but it only says they cannot have more than the set limit. I am sorry if you have expected anything else but that is what I got from the description of this thread, it doesn’t say anything about payment, I created this solution based on this:

    Pro Sites Plugin should have the option to limit “the number of blogs a user can create” for different levels.

    And this does not say anything about allowing one payment per level so I am sorry I missed anything here. Unfortunately, I have checked Pro Sites and do not see any hooks to achieve this so I am afraid you will have to hire a developer to do this for you as it will require more than the solution on this thread and there are small chances you can do this without modifying the Pro Sites core. Such a solution is beyond the scope of this support platform and we can not do custom development here so you will have to go to our Jobs & Pros section and hire an independent developer.

    I am sorry for any misunderstandings and inconveniences. Please let me know if there is anything else I should look into.

    Have a nice day.

    Lindeni

  • silvio
    • Design Lord, Child of Thor

    Hi Lindeni,

    yes, I need same when anyone purchase “Premium” level then they create 5 blogs only one-time payment. when they create 6 then, it will display your limit is crossed.

    I have enabled “Grant Access” from WPMU Dev. So kindly check and fix this issues.

  • Lindeni Mahlalela
    • Recruit

    Hello silvio

    I hope you are doing great today. Thanks for the feedback.

    Unfortunately what you require here is more than what we offer on this support forum and this is not an issue with Pro Sites or the code provided, what you require is completely new functionality currently not built into Pro Sites. When we provide code on a support ticket, we do so to guide you or to give you information and examples on what you should do to accomplish your goals. We do not do custom solutions on the forums, for that you will have to visit our Jobs & Pros page where you can post your project and hire a professional independent developer to add the custom functionality for you.

    With regards to the request of requiring one payment per level, I must say this is way too complex for the scope of this support forum and even if you had to hire a developer there is a lot of word that needs to be done to make it work the way you want it to work.

    But for the sake of helping you launch your website, I have come up with a workaround to at least get the basics done but it is NOT a permanent solution for this. This is how the workaround works.

    1. Activate the Manual Payment gateway in ProSites to allow signups without requiring payment

    2. Keep the existing payment gateways they are

    3. Download the attached ‘limitblogs.zip’ , extract it and replace the file pro-sites/pro-sites-files/modules/limitblogs.php with the one from the zip file.

    What this will do is check if you the user has at least one blog paid on the selected level, if they do it will hide the payment gateways that require payment and only leave the manual gateway visible so they can submit without going through payment. If they do not have a paid blog for the selected level then it will hide the manual payment option and leave the other two gateways visible so they will not be able to proceed without going through payment. This is just a workaround and should be changed immediately once you have managed to get your site up.

    I can express how important it is that you take this as a temporal workaround and consider hiring a developer to make a permanent solution. Please note that this is not in the plans to be included in Pro Sites soon so it will be to your advantage to get a permanent solution and unfortunately that is beyond the scope of this support forum.

    If you believe this should be included in Pro Sites then consider creating a feature request , note that there was already a requested feature for only limiting the number of blogs per level per user and I will submit the code here to developer for review (Without the payment part for now) and if developer approves it it will be included in future releases but you will still have to add the part that requires one payment per level.

    I hope this helps.

    Have a nice day.

    Lindeni

  • silvio
    • Design Lord, Child of Thor

    Hello Lindeni,

    I implemented the code but it’s not working as I need,

    after Purchase “Basic Level” I am able to create only one blog at the time of registration but after this when I click on creating another blog its redirect on Pricing table to purchase again that is wrong.

    I need the complete working code.

  • Lindeni Mahlalela
    • Recruit

    Hello jetmac

    I hope you are doing great today. I am really sorry for the delayed response from our side.

    I implemented the code but it’s not working as I need, after Purchase “Basic Level” I am able to create only one blog at the time of registration but after this when I click on creating another blog its redirect on Pricing table to purchase again that is wrong.

    I am sorry about that, but checking the above link it still says 0 downloads on the file I shared which possibly means it was not downloaded. To verify I inspected the source of your page on /upgrade and I noticed that the JavaScript code included in the code shared above was not shown on the page source, it was still showing the old code, which again shows the new code was not implemented. Would you mind sharing how you implemented the change?

    Luckily, I found the FTP login details you shared with my colleagues and I have then implemented the code for you, with minor changes as well.

    I have tested it on your site and it seems to work. In summary here is how it works:

    1. User signup for any level, lets say “Basic” for example. They pay the price for that level.

    2. They signup for for the same level:

    – ProSites checks if they have reached blog limit, if they did it shows the message and hides the signup forms

    – If they can still publish, it checks if the have a paid blog in the chosen level, if they do, it hides the payment gateways and show the manual gateway so they can signup without paying otherwise it hides the manual gateway and reveals the others to force the to pay.

    – It does this for all levels until all limits are reached.

    I hope this works for you as well. In the future, if we ask you to download something and test it, please do so it will save you a lot of time as you will be able to do things on your side without waiting for us.

    I have also tried this forum, but still getting same issues …

    I have seen that link and the plugin as well it also tries to solve the number of blogs per user only it does not take into account the payment flow you require. Also, the plugin does not integrate with Pro Sites and is very old as you have already mentioned so it won’t recognize Pro Sites levels and payments but it will only limit the number of blogs at Pro Sites level, I am sure you have seen that already.

    I have now uploaded the code for you so you can just test if it works and take it from there. I am sorry I didn’t upload it before I only mentioned that you should upload it because I didn’t want to break thing while you are busy working.

    While working on your site I also noticed that there are some other things that are interfering with your site, the main one is that the browser reports insecure content loaded and when this happens some of the scripts break and can’t function properly as there are undefined JavaScript variables that are being loaded. I found one such plugin loading insecure content was the Multi Social Widget and there is another one injecting a twitter widget script, I didn’t find which one that plugin is but these break important functionality like in one instance Stripe was not working properly because of the undefined JavaScript variables. So please also check such plugins and contact their respective developers to fix this otherwise a lot of things may stop working and you will wonder why.

    Please let us know how it goes and we will be happy to assist in anyway possible but if you need any further modifications or additional features please visit the Jobs & Pros dashboard and hire a developer who can implement a solid solution for you, I say this because what I provided here is a workaround for the payment flow, creating a solid solution is beyond the scope of this support forum.

    Have a nice day.

    Lindeni

  • silvio
    • Design Lord, Child of Thor

    Hello Lindeni,

    what have you implemented on the site?

    Because it’s not working properly right now.

    after signup for any level its redirect on upgrade page, previously its working fine.

    have you checked after implementing “Number of blog per level” code?

    I have enabled Paypal to sandbox it’s not going to PayPal for payment, I think you have done any wrong.

    Please, check and fix that as soon as possible.

  • Panos
    • SLS

    Hi silvio ,

    It seems that the initial description led to wrong conclusions on what you require :slight_smile:

    In the initial post it looked that you are searching for a way to limit the number of total blogs a user can create (or be charged for ). An example for this is that user can subscribe 5 times for the “Starter Level”, which means he is allowed to create 5 sites with that level. This is something that current Pro Sites filter would allow to accomplish.

    Continuing reading though I understand that you need something different. You want to allow members to have a number of additional sites for free if they subscribe for a level. Although this is possible it is not something that Pro sites is designed for. It does require custom coding for this and exceeds the scope of the support forum.

    However I have prepared a custom mu-plugin that you can try out instead of previous solution. It is not a complete solution, it requires UI improvements, but it can be used as a guide :slight_smile:

    You can download it from here :

    https://gist.github.com/wpmudev-sls/206fae3dc5df8ee11a8e31267635314b

    It doesn’t provide a ui on where to manage the levels and number of allowed blogs. That can be set by modifying this part of the file:

    $this->sites_per_level = array(
    '1' => 3,
    '2' => 5,
    '3' => 8
    );

    This means that for

    level 1 a user can have 3 sites,

    for level 2 he can have 5 and

    for level 3 he can have 8

    Change this accordingly and upload it to your mu-plugins folder.

    After you subscribe for a level, once you go to the checkout page and click on the Sign up for another site. link, there should be a new table at the top of the page, that informs member that he can create additional sites for that level.

    Hope this helps :slight_smile:

  • Panos
    • SLS

    Hi there silvio ,

    I found some ftp info but unfortunately it’s not working. Could you please send ftp info once more? You can send that privately through our contact form: https://premium.wpmudev.org/contact/#i-have-a-different-question

    Send in:Subject: “Attn: Panos Lyrakis”

    – FTP credentials

    host

    username

    password

    (and port if required)

    – link back to this thread for reference

    I checked the admin info and I can connect to admin, but I also need ftp to figure out why it doesn’t redirect to PayPal.

    Thanks!

  • James Morris
    • WordPress Enthusiast

    Hello silvio

    I’m afraid there’s nothing further I can do for you on this issue as it has been escalated to a higher level of support, other than ping our SLS Team again. I have notified Panos as well as the SLS team again.

    I’m terribly sorry for the delays on this. Our team will reply as soon as possible.

    Best regards,

    James Morris

  • Panos
    • SLS

    Hi silvio ,

    So sorry for delay here.

    Indeed it is not redirecting to PayPal after clicking the PayPal button. The $_POST variable is getting empty from somewhere. This is not related with Lindeni’s work though as I have installed latest version of ProSites. I have kept a backup of the previous version you had installed. I have renamed it to pro-sites__ORIG__.

    In case you want to restore it you can delete (or rename) current pro-sites folder and rename the old one back to pro-sites.

    I would suggest to deactivate all plugins, rename the mu-plugins folder and switch to a basic wp theme (eg twenty seventeen) to check where the $_POST is getting deleted. This happens for any form submit on that specific page. I added a custom irrelevant form and the $_POST was empty after submitting. But same form would work in a test page I created on your site.

    However I have created a new mu plugin that would override the initial form submit and uses ajax to get the paypal url and token and redirects with js. I tested it and it redirects correctly. You can find that mu-plugin in wp-content/mu-plugins/ps-pp-redirect.php

    I noticed though that the levels are not being set after payment and that the payment logs are missing information. Have you set the IPN url in your sandbox account?

    Finally, I also added the mu-plugin regarding the free levels if user already has a site with a pro level: wp-content/mu-plugins/ps-sites-per-level.php

    I tested it by manually setting a test site to a pro level and seems to work on my side.

    Kind regards!

  • silvio
    • Design Lord, Child of Thor

    Hello Panos,

    I have implemented the previous code of Number of blog per level in New version pro-plugin,

    but still getting “Number of blog per level” not working for current Users who take the plan.

    check and fix that as soon as.

  • silvio
    • Design Lord, Child of Thor

    Hello Panos,

    I was implemented code line as per your post, I have mentioned below.

    “In the initial post it looked that you are searching for a way to limit the number of total blogs a user can create (or be charged for ). An example for this is that user can subscribe 5 times for the “Starter Level”, which means he is allowed to create 5 sites with that level. This is something that current Pro Sites filter would allow to accomplish.

    Continuing reading though I understand that you need something different. You want to allow members to have a number of additional sites for free if they subscribe for a level. Although this is possible it is not something that Pro sites is designed for. It does require custom coding for this and exceeds the scope of the support forum.

    However I have prepared a custom mu-plugin that you can try out instead of previous solution. It is not a complete solution, it requires UI improvements, but it can be used as a guide :slight_smile:

    You can download it from here :

    https://gist.github.com/wpmudev-sls/206fae3dc5df8ee11a8e31267635314b

    It doesn’t provide a ui on where to manage the levels and number of allowed blogs. That can be set by modifying this part of the file:

    $this->sites_per_level = array(

    ‘1’ => 3,

    ‘2’ => 5,

    ‘3’ => 8

    );

    This means that for

    level 1 a user can have 3 sites,

    for level 2 he can have 5 and

    for level 3 he can have 8

    Change this accordingly and upload it to your mu-plugins folder.

    After you subscribe for a level, once you go to the checkout page and click on the Sign up for another site. link, there should be a new table at the top of the page, that informs member that he can create additional sites for that level.”

    After purchasing any Plan by users, Users not getting any “Sign up for another site” link on the pricing table.

    Please, take a look into this and fix this soon,

    Thanks

  • silvio
    • Design Lord, Child of Thor

    Hello Kasia,

    Yes, I also get “Sign for another site”, but after when clicking on “Sign for another site”it’s asking another site name, its good but after clicking reserve the site its again redirect for payment for those Users who already taken the plan that allows creating a number of blog per level, this is not good.

    I need to fix this issues, that means after taking any plan users will create the Number of Sites as per taken plan.

  • Kasia Swiderska
    • Support nomad

    Hello silvio,

    Okey, I can see the issue – I have tested this also on my site and link for creating new sites is not responding (on both yours and my site)

    I'm reporting this to Panos and seems there is problem with Ajax request that should be firing after clicking that link.

    Please make sure that you have correct credentials to sandbox PayPal account and IPN is enabled for that account – while testing I noticed that my account wasn't Pro level as there was issue with payments and I had to extend the Pro Level Manually to see options from this add-on.

    kind regards,

    Kasia

  • Panos
    • SLS

    Hi silvio ,

    I checked this on Kasia's site and the issue there is related to coolies which would cause nonce check to fail.

    I have updated the snippet on gist so it now creates a custom nonce. If you have the same issue with Kasia then the new snippet should create the site. It's the same link as previously:

    https://gist.github.com/wpmudev-sls/206fae3dc5df8ee11a8e31267635314b

    You can check the revision to see the code changes on gist.

    If t is not working, could you please confirm that you are using the correct form? That form should look like the following screenshot:

    Clicking on the Create new site link should create the new site via ajax.

    Kind regards!

  • silvio
    • Design Lord, Child of Thor

    Hello Panos,

    I have updated "ps-sites-per-level.php" with your shared GitHub link, but it's not showing screen as you shared for "Create New Site".

    after clicking Add new Site from Current Active Plan it's showing the following details, Screenshot attached.

  • Panos
    • SLS

    Hey silvio ,

    Just need to mention that this is a custom request and exceeds the scope of our support. We do our best to help out on custom requirements but in cases you feel it takes too long you can hire a dev from the jobs board :

    https://premium.wpmudev.org/wordpress-development/

    I had a look and it worked on my side, only issue is that it was not working properly for sub-domain installations, it created the new sites but it would add a wrong path. I have made additional changes on the mu-plugin on your site and seems ok to me. I have made a short screencast :

    https://streamable.com/2izuk

    Please let us know how this goes on your side too :slight_smile:

    Kind regards!

  • silvio
    • Design Lord, Child of Thor

    Hello Panos,

    Yes, I have checked from my side it’s working, but the assign limitation for Number of blog per level not working that means, I was tried with Premium Level that has 5 limits for creating the subsite, but after creating 5 sites by that users, he again create 6th site, that is wrong it would get message for you to have only 5 limits for creating Subsite.

    Please, check this from your side.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.