Support » Plugin: Private Content » Subscriber-only role doesn’t work

  • Resolved atenedelcanavese

    (@atenedelcanavese)


    Hi,
    I’ve installed and activated “Private Content” plugin (ver.6.3.1) on wp5.6
    On my portfolio, on the top of the page I’m using code:
    [private role=”subscriber-only”]Text for subscriber only[/private]
    and update page.
    Using other browser (google chrome on macosx), after login with user having subscriber role, I can’t see the text “Text for subscriber”.
    What can I’ve to check?
    Thanks for your support

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Aldo Latino

    (@aldolat)

    Hi,
    please, try this shortcode:

    [private role="subscriber-only" alt="You're not a Subscriber!"]Text for Subscribers only[/private]

    and visit the front-end page with your Administrator account. What do you read?

    Thread Starter atenedelcanavese

    (@atenedelcanavese)

    Hi,
    after login as Administrator and visiting page I read:
    You’re not a Subscriber

    Can I use shortcode to show the role of the user I’m logged in?

    Thread Starter atenedelcanavese

    (@atenedelcanavese)

    Hi,

    I’ve created a new portfolio and used shortcode:
    [private role=”administrator”]Text for administrator[/private]
    [private role=”editor”]Text for editor[/private]
    [private role=”editor-only”]Text for editor-only[/private]
    [private role=”author”]Text for author[/private]
    [private role=”author-only”]Text for author-only[/private]
    [private role=”contributor”]Text for contributor[/private]
    [private role=”contributor-only”]Text for contributor-only[/private]
    [private role=”subscriber”]Text for subscriber[/private]
    [private role=”subscriber-only”]Text for subscriber-only[/private]
    [private role=”visitor”]Text for visitor[/private]
    [private role=”visitor-only”]Text for visitor-only[/private]
    [private role=”none”]Text for none[/private]
    [private role=”custom”]Text for custom[/private]
    [private role=”custom-only”]Text for custom-only[/private]

    After that, using a new browser, I logged-in with different users having different roles (Administrator too). For all the output is the same:

    Text for visitor
    Text for visitor-only

    I’ve also reinstalled the plugin. But the result doesn’t change.

    Plugin Author Aldo Latino

    (@aldolat)

    Hi,
    after login as Administrator and visiting page I read:
    You’re not a Subscriber

    This means that the plugin is working as expected.

    Can I use shortcode to show the role of the user I’m logged in?

    No, this function is not implemented inside the plugin. But I have an advice for you: you can use the great plugin User Switching to test what a given user can see in your site. I use it regularly to test the functionality of Private Content.

    From the description of that plugin:

    This plugin allows you to quickly swap between user accounts in WordPress at the click of a button. You’ll be instantly logged out and logged in as your desired user. This is handy for test environments where you regularly log out and in between different accounts, or for administrators who need to switch between multiple accounts.

    Perfect for testing Private Content.

    Plugin Author Aldo Latino

    (@aldolat)

    In order to display your current user roles, you can use a function like this:

    /**
     * Show the current user role.
     */
    function ubn_show_current_user_role( $text ) {
    	$user  = wp_get_current_user();
    	$roles = '';
    	foreach ( $user->roles as $role ) {
    		$roles .= $role . ', ';
    	}
    	return '<p style="background-color: red; color: white; font-weight: bold; padding: 1.2em;">Your current roles:<br />' . rtrim( $roles, ', ' ) . '.</p>' . $text;
    }
    add_filter( 'ubn_private_text', 'ubn_show_current_user_role' );
    add_filter( 'ubn_private_text_empty', 'ubn_show_current_user_role' );

    This should be added in your current theme functions.php file.

    This function will display all the roles of the user you are impersonating. Use this function only for debug purposes.

    Plugin Author Aldo Latino

    (@aldolat)

    I’ve created a new portfolio and used shortcode:
    […]
    After that, using a new browser, I logged-in with different users having different roles (Administrator too). For all the output is the same:

    Text for visitor
    Text for visitor-only

    I’ve also reinstalled the plugin. But the result doesn’t change.

    This means that something is not working as expected. In this cases I always advice to deactivate all the plugins (except Private Content) and activating one of the WordPress default themes. This is perfect to make a test in a clean environment.

    Let me know, please.

    Thread Starter atenedelcanavese

    (@atenedelcanavese)

    Hi,
    I’ve done a lot of test. Below my conclusion.

    If I use firefox browser (78.6.1esr (64 bit)) it works fine: I see the right shortcode as expected.
    If I use Chrome browser (Versione 65.0.3325.181 (Build ufficiale) (a 64 bit)) it doesn’t work: I always read shortcode as Visitor/Visitor-only.

    For login/logout I’m using “Ultimate member” plugin (Versione 2.1.15).

    Any other suggestions?

    Plugin Author Aldo Latino

    (@aldolat)

    If Firefox works, also Chrome should work. On my testing sites both Firefox and Chrome work as expected.

    Try using a brand new Chrome session without any extension.

    Let me know, please.

    Thread Starter atenedelcanavese

    (@atenedelcanavese)

    Hi,

    I’ve problem only using Chrome 65.0.3325.181 64bit on MacOSX 10.9.5 (old release, no more supported by Google Chrome).
    All other configurations work fine.

    Thanks for your precious support.

    Giampaolo

    Plugin Author Aldo Latino

    (@aldolat)

    Hello Giampaolo,
    you’re very welcome!

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.