• Resolved stewart8080

    (@stewart8080)


    I have a member site where the members email address to access the site are the same as the email address on cPanel.

    The logged in user needs to be able to access their own cPanel webmail via the sites front end as they won’t have access to the WordPress admin area.

    They must only be able to access their own email account and no other users.

    Is your plugin able to do this?

    If not would you be able to add this function in the near future?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Knut Sparhell

    (@knutsp)

    It’s supported. Simplest, add a ‘cpanel’ custom capability to their user roles using a roles/capability manager like your Members plugin or other.

    Thread Starter stewart8080

    (@stewart8080)

    Hi, that’s great news thanks.

    I don’t know what I am doing wrong though as I am using “User Role Editor” and can’t find a custom capability for ‘cpanel’. Am I missing something or have I got to add something to the functions.php file?

    Plugin Author Knut Sparhell

    (@knutsp)

    Can’t you create a custom capability ‘cpanel’ and add it to the role?

    Thread Starter stewart8080

    (@stewart8080)

    Hi

    Got the cPanel role added thanks.

    Is there a call I need to make or shortcode I have to use in the front end of the site for the user to access their email account? bearing in mind they don’t have access to the admin area.

    Many thanks

    Plugin Author Knut Sparhell

    (@knutsp)

    Sorry, no.

    This plugin only works in the admin area. The current Webmail session is created for any, and may be used if the button is seen.

    But it’s a good idea. I’ll think about it for the next version. Must also be a block, I think, as I generally dislike shortcodes.

    I never restrict registered user form the admin area. The capability system ensures they only see (or can chenge) what they are allowed to. The read capability gives access, plus the cpanel capability. Other stuff they see are public, or by default considered public.

    Plugin Author Knut Sparhell

    (@knutsp)

    Thinking about it. You may try

    $email = wp_get_current_user()->user_email;

    The use this $email to get

    $session = WebFacing\cPanel\UAPI::create_webmail_session( $email );
    $action = 'https://' . $session->hostname . ':2096' . $session->token . '/login';

    The use this $session object and $action url in a
    <form method="post" action="<?=$action"><input type="hidden" name="session" value="<?=$session->session?>"/><button type="submit">Your Webmail</button></form>

    Plugin Author Knut Sparhell

    (@knutsp)

    In case your $session->hostname is empty, use your site hostname or cPanel server native hostname.

    Thread Starter stewart8080

    (@stewart8080)

    Hi

    That’s fantastic thanks.

    I have added the code in to a function and it does get called but I am getting the following fatal error

    Fatal error: Uncaught Error: Typed static property WebFacing\cPanel\Email\Main::$pf must not be accessed before initialization in /wp-content/plugins/wf-cpanel-email-accounts/includes/UAPI.php:124

    I’ll have a think over the weekend to see if I can get it working.

    Plugin Author Knut Sparhell

    (@knutsp)

    Working on it myself.

    Plugin Author Knut Sparhell

    (@knutsp)

    Almost finished. It works! Will be in v4.5, probably Monday.

    Plugin Author Knut Sparhell

    (@knutsp)

    v¤.5-beta is out, with shortcode support! Please download and test the current development version.

    Parameters (not set in stone yet):
    email,
    target,
    before_form,
    after_form,
    form_class,
    button_class,
    not_logged_in,
    no_account

    All parameter defaults can be filtered by add_filter('wf_cpanel_email_shortcode_webmail_$attribute', fn()=>'your-value' ); (replace the $attribute part by the parameter to filter.

    Plugin Author Knut Sparhell

    (@knutsp)

    v4.5 was just released.

    Thread Starter stewart8080

    (@stewart8080)

    fantastic, works perfect thank you ??

    Plugin Author Knut Sparhell

    (@knutsp)

    Nice. Please write a review.
    For bugs, new features, please strat a new thead.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘User access to their own webmail account only’ is closed to new replies.