• Resolved hasinasayan

    (@hasinasayan)


    Hello!
    I would like to have this function :
    – when the user (not admin) is logged, the site redirect user to home page
    – and when the user(logged) click to dashbord, it redirect to another page (not the originale dashbord of wordpress back end ) who have different menu : * profile
    * loggout
    – and if the user (logged) clik the menu profile, it redirect to /wp-admin/profile.php
    I have tried this snippet

    function prevent_profile_access() {
       		if (current_user_can('subscriber')) {
    		
       		if (strpos ($_SERVER ['REQUEST_URI'] , 'wp-admin/profile.php' )){
          		wp_redirect (home_url('/candidat_dasboard'));
                die();
    		}}
     return '';

    but when I want to go to /wp-admin/profile.php, it redirect me to the same page (candidat_dashbord).
    Please,How to solve this?
    the wordpress site use ACF plugin for display content

    Could I have a custome dashbord without using another plugin?please!!!
    code snippet are welcome because I work in wordpress site with a personalized theme.

    Thanks in advance

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    I think your goal is to prevent profile.php requests except when following a menu link from your alternate dashboard page. Following that menu link should work as expected. Am I right?

    Then you need to also check $_SERVER['HTTP_REFERER'] as part of your check for profile.php requests, e.g.:

    IF the request is for profile.php AND the referrer is NOT candidat_dasboard, then redirect to candidat_dasboard.

    ^^ code that ??

    Thread Starter hasinasayan

    (@hasinasayan)

    Thanks for your answer,

    ok i will tried that!

    But how exactly to code that?

    ??

    • This reply was modified 6 years, 8 months ago by hasinasayan.
    Moderator bcworkz

    (@bcworkz)

    if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin/profile.php') &&
       ! strpos( $_SERVER['HTTP_REFERER'], '/candidat_dasboard')){
          wp_redirect( home_url('/candidat_dasboard'));
    }
    Thread Starter hasinasayan

    (@hasinasayan)

    Thank you very much @bcworkz!!! it WORK great!!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘create a custome dashbord (without plugin)’ is closed to new replies.