• Resolved sslv

    (@sslv)


    Hi,

    I have created two forms in UsersWP. One to register Barbers and another one to register Barber Shops for my websites. But I have issues with profile of administrators.

    In total I have 3 main roles in my website:

    • Barber should have these tabs: tab1, tab2, tab3
    • Barber Shop should have these tabs: tab4, tab5
    • Administrator should have these tabs: tab1, tab2, tab3, tab4, tab5
    • I can control the tabs shown in the profiles of Barbers and Barber Shops but I don’t know how to control the Profile Tabs for Administrators. For the moment it shows the same tabs as a Barber (tab1, tab2, tab3).

      https://paste.pics/e326285934ec012d227a870c407856fa

      Let me know for any solutions. I want the tabs for the Admin to be as shown in the screenshot

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter sslv

    (@sslv)

    Here is the code I use to display shops of each current profile as a TAB, but doesn’t work properly:

    /* ADD NEW PROFILE TABS IN PROFILE */
    if ( is_user_logged_in() ) {
    	
    	//Get currently logged in user:
    	global $current_user; 
    	get_currentuserinfo();
    
    	//For each ROLE:
    	switch (true)  {
    		//IF BARBER:
    		case ( user_can( $current_user, "barber") ):
    			add_shortcode('list_shops_in_current_profile', 'display_shops_in_current_profile', 10, 1);
    			break;
    
    		//IF BARBER SHOP:
    		case ( user_can( $current_user, "barber_shop") ):
    			add_shortcode('list_shops_in_current_profile', 'display_shops_in_current_profile', 10, 1);
    			break;
    
    		//IF ADMINISTRATOR:
    		case ( user_can( $current_user, "administrator") ):
    			add_shortcode('list_shops_in_current_profile', 'display_shops_in_current_profile', 10, 1);
    			break;
    	}
    	
    }
    
    function display_shops_in_current_profile(){
    
    	//Get user id of displayed profile:
    	$user = uwp_get_displayed_user();
    	$role = $user->roles[0];
    
    	$id = $user->ID;
    
    	//Query to return shops using user's id:
    	$post_query = new WP_Query(array(
    		'author'    =>  $id,
    		'post_type' => 'gd_place'
    	));
    
    	//If results not null:
    	if($post_query->have_posts() ) {
    
    		$numOfShops = $post_query->found_posts;
    ?>
    
    <!-- CREATE CONTAINER TO HOLD SHOPS -->
    <br>
    <br>
    <div class="container">
    	<div class="row">
    
    		<?php
    		//FOR EACH POST CREATE A CARD:
    		while($post_query->have_posts()) {
    
    			$post_query->the_post();//GET POST OBJECT
    			$i = $post_query->current_post;//GET LOOP INDEX
    			$BS_location_id = get_the_id();//GET POST ID
    			$view_BS_loction_URL = get_the_permalink();//URL FOR VIEW LOCATION
    		?>		
    
    		<div class="col-lg-4 d-flex align-items-stretch mb-4">
    			<div class="card">
    				<img style ="width: auto;  height: 200px; object-fit: cover;" src="
    																				   <?php 
    			if (has_post_thumbnail()) {
    				$thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail_name');
    				echo $thumb[0]; // thumbnail url
    			} 
    																				   ?>
    																				   " class="card-img-top" alt="">
    				<div class="card-body">
    					<h5 class="card-title"><?php the_title(); ?></h5>
    					<?php echo do_shortcode("[gd_single_taxonomies taxonomy='' prefix='' link_style='' link_color='' link_color_custom='' link_icon='false' mt='' mr='' mb='2' ml='' pt='' pr='' pb='' pl='' ]
    ");?>
    				</div>
    				<div class="card-footer d-grid gap-2">
    					<a class="btn btn-primary w-100" href="<?php echo $view_BS_loction_URL?>" role="button" style="margin-top:6px;"><i class="fas fa-eye"></i> View Shop</a>
    				</div>
    			</div>
    		</div>
    		<?php
    
    //Create new row after 3rd element
    if(($i+1) % 3 == 0){
    		?>
    	</div> <!-- End of first initial row -->
    	<div class="row">
    		<?php
    }
    		} //end of while loop
    		?>
    	</div> <!-- End of final Row -->
    </div> <!-- End of Container -->
    
    <?php
    
    	}//end of if statement (post_query)
    	else{ //if user doesn't have shops
    ?>
    		<h1 style="color:white;">This user doesn't not have a shop yet</h1>
    <?php
    	}
    }

    Hi,

    If you want to keep the admin as a different user then you can create a new form for that and you will get an option for that in the profile tab builder to choose tabs for forms.

    Regards,
    Patrik

    Hi, just a quick follow-up.

    Was the issue solved for you or do you need any help?

    Regards,
    Patrik

    Thread Starter sslv

    (@sslv)

    Hi Patrik,

    Thanks for your reply. I will try that now and let you know if I face any difficulties.

    Thanks,
    SSLV

    Thread Starter sslv

    (@sslv)

    Hi Patrik,

    Just one question. I have noticed that the selection of which form to display disappears when in Register page. But works fine with light-box. So my question is how to display Option to select which user role (=which form) to display in Register Page. See screenshot: screenshot 1

    Or is there a way to completely get rid of the Registration Page and only have the lightboxes to work with?

    Thanks,
    SSLV

    • This reply was modified 2 years, 10 months ago by sslv.
    Thread Starter sslv

    (@sslv)

    I have also noticed that for existing Administrators it will still consider them as Barbers and display the tabs for barbers.

    But when I created a new administrator it shows the preferred tabs as shown in the screenshots below:

    OLD ADMIN SCREENSHOT

    NEW ADMIN SCREENSHOT

    Is it possible to fix without deleting and re-creating old admin?

    Thanks for your time,
    SSLV

    Hi,

    We have a param called ‘limit’ in shortcode which accepts comma separated form IDs of register forms to display on the register page. If you are using a widget then you can set comma separated form IDs in the ‘Display form having IDs’ option. If you don’t want to use the registration form on the page then you can delete the page.

    Regards,
    Patrik

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Manage Profile Tabs and User Roles’ is closed to new replies.