orlafitz
Forum Replies Created
-
The issue was that the global variable had changed in UM 2.0 with $ultimatemember->user->get_role() now changing to UM()->user()->get_role() – they haven’t gotten around to changing the docs yet. With a little more help from Ultimate Member support here is the full working code incase anyone ever needs it :-):
$user = wp_get_current_user(); if ( in_array( 'um_member', (array) $user->roles ) ) { // DO THIS IF USER IS A MEMBER } else { // DO THIS IF USER IS NOT A MEMBER }
Thank you for all your help TXPMR – without the updated docs we couldn’t have figured this one out :-D!
I am calling it in the functions file – the purpose of the if statement is to determine if the user is assigned a role – if not do nothing. The script doesn’t seem able to connect to the Ultimate Member role ID ‘um_member’. It seems like there is a piece of the puzzle missing but I don’t have enough experience with PHP to figure it out. It is a pity that there are no developers from Ultimate Member on this support forum – perhaps I will try Stack Overflow.
I’ve been through every permutation of the shortcodes – using do_shortcode(‘ [um_show_content roles=’member’]’); but that threw up errors
(syntax error, unexpected 'member' (T_STRING))
which was why I moved on to the solution I am working on. The logic of the current solution makes more sense to use but I just can’t figure out how to get Ultimate Member to work with the functions file.Yup – same error comes up – it seems like I am missing a variable. Do I need to do something to define get_role_name() or get_role().
I’ve also tried dynamically fetching the user_id:
um_fetch_user( get_current_user_id() ); if ( $ultimatemember->user->get_role_name() == ‘Member’ )
I keep getting the same error
Call to a member function get_role_name() on null
Hi Txpmr,
Thank you for the reply but am still gettingCall to a member function get_role() on null
Full code as implemented in functions.php:
// If User is not logged in don't allow them to purchase if ( $ultimatemember->user->get_role() == ‘Member’ ) { //if ( is_user_logged_in() ) { } else { //function for deleting .... function remove_product_description_add_cart_button(){ global $product; // Set HERE your category ID, slug or name (or an array) $category = 'restricted'; //Remove Add to Cart button from product description of product with id 1234 if ( has_term( $category, 'product_cat', $product->id ) ) remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); } add_action('wp','remove_product_description_add_cart_button'); }
- This reply was modified 6 years, 7 months ago by orlafitz.
I am facing the same issue – following for a resolution.
I am not using it with Woocommerce.
I have uninstalled and re-installed the plugin and the problem persists. The .onclick function is firing and it redirects to /?action=del&pid=1136&_wpnonce=691181a2d5 but the post is still there.
Forum: Plugins
In reply to: Add custom field link through functions.phpAll delighted with myself that I figured it out – I wasn’t closing the php statement before starting the html! So the answer was:
add_action( 'woocommerce_single_product_summary', 'poppy_pdf_brochure', 20); function poppy_pdf_brochure() { ?> <a href="<?php echo the_field("product_brochure"); ?>" >Brochure</a> <?php }
Forum: Plugins
In reply to: [Simple Calendar - Google Calendar Plugin] Widget breaking footerThe problem was a broken div in the text input area – I couldn’t see what was causing it so I just deleted out the manual markup and enabled the right hand panel instead. Works perfectly now.
I’ve the same problem as Judie since the new updates. Its a new installation running Divi theme – which was never a problem before. I had to roll back to V.2.0 to get back the ability to choose the sidebar on each individual page. I have very few plugins installed as this is a brand new site.
Am assuming since so many people are having this issue – it is something that needs to be fixed in the plugin.
Forum: Plugins
In reply to: [Sociable] how do you insert the sociable links manually?Hi All,
I’ve tried inserting both of these pieces of code into my index.php page as I want to get sociable to move above my adsense plugin but nothing at all happens! I don’t understand the code at all so exactly where should I paste that line of code in my Main Index Template:
[Code moderated as per the Forum Rules. Please use the pastebin]
Thank you so much for your help!
Forum: Themes and Templates
In reply to: Urgent – Horizontal Menu Bar MissingHi all,
The answer is achingly simple… In WP 3.0 under the ‘menu’ section of the appearance panel, add all of the pages you want. Place the pages you want as sub menu’s under your main page tab and then ‘pull’ your sub page tabs to the right – they will dock indented to the right & hey presto – drop down menu created! Fantastic
I hope this saves someone else some frustration! WordPress 3.0 is brilliant!
Forum: Themes and Templates
In reply to: Urgent – Horizontal Menu Bar MissingIt seems to be to do with upgrading to 3.0. I got the menu’s back by using the new built in feature in WordPress but does anyone know if it supports drop down menus. My menu’s used to be drop down & I can’t see a way to make this happen again despite the fact that my theme supports them?
Forum: Themes and Templates
In reply to: remove space above header imageThank you both so much for the quick reply – that was the padding that was throwing it all off! Twas driving me crazy.
Thanks again!