Code Snippets for v2

Basically, code snippets for WordPress are used to do certain actions that might otherwise require a dedicated smaller plugin. Such code snippets are placed in one of the WordPress core or theme files (generally the functions.php file of your theme) or they can be used as a MU plugin.

On this article we will show you three code snippets that can be used with WP Ultimo v2:

Changing the position of the Account menu item

To change the position of the Account menu item on your client’s Dashboard, just add the following code snippet to the functions.php of your main site’s active theme. You can also put the snippet inside one of you mu-plugins or custom plugins.

<code>add_filter('wu_my_account_menu_position', function() {<br>  return 10; // Tweak this value to place the menu in the desired position.<br>

How to check if user is under a given plan and/or have an active subscription

As a network admin you may need to create custom functions that will perform basic actions or make a service/feature available to a selected group of subscribers or end-users, based on the status of their subscription and "plan" they are subscribed under.

These WP Ultimo native functions will help you with that.

To check if the user is a member of a given plan, you can use the function:

<code>wu_has_plan($user_id, $plan_id)

To check if the subscription is active, you can use the function:


Below is an example snippet that check whether the current user is under a specific plan ( Plan ID 50) and if the user subscription is active.

<code>$user_id = get_current_user_id();<br>$plan_id = 50;<br><br>if (wu_has_plan($user_id, $plan_id) && wu_is_active_subscriber($user_id)) {<br><br>  // USER IS MEMBER OF PLAN AND HIS SUBSCRIPTION IS ACTIVE, DO STUFF<br><br>} else {<br><br>  // USER IS NOT A MEMBER OF PLAN -- OR -- HIS SUBSCRIPTION IS NOT ACTIVE, DO OTHER STUFF<br><br>} // end if;

Note that  wu_has_plan requires a "Plan ID" in order for it to function.

To get the ID of a plan, you can go to WP Ultimo > Products. The ID of each product will be show on the right of the table.

Note that users can only be subscribed to a Plan, not a Package or Service, as they are only add-ons for a Plan.

Fixing CORS issues with Font-Icons in mapped domains

After mapping a domain to a sub-site you might find out that site having trouble to load custom fonts. That’s caused by a cross-origin block on your server settings.

Since font files are almost always loaded directly from CSS, our domain mapping plugin is not able to rewrite the URLs to use the mapped domain instead of the original one, so in order to fix the issue, you’ll need to amend your server configuration files.

Below are code snippets to fix the issue for Apache and NGINX. These changes require advanced knowledge about server configuration files (.htaccess files and NGINX config files). If you are not comfortable with making those changes yourself, send this page to your hosting provider support agents when requiring assistance.


On your .htaccess file, add:

<IfModule mod_headers.c><br><br><FilesMatch “\.(ttf|ttc|otf|eot|woff|font.css|css)$”> Header set Access-Control-Allow-Origin “*” </FilesMatch><br><br></IfModule>


On your server config file (the location varies from server to server), add:

location ~ \.(ttf|ttc|otf|eot|woff|font.css|css)$ {<br><br>  add_header Access-Control-Allow-Origin “*”;<br><br>}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.