코스모스팜 회원관리 사용자 숏코드 응용

안녕하세요

코스모스팜 회원관리 플러그인을 이용하고있는 사람입니다

회원관리를 자신이 원하는데로 커스터마이징을 해서 사용할수있다는것이 너무나도 큰 장점인것같습니다

지난 질문들을 바탕으로 커스터마이징을 하고있는데 잘안되서 이렇게 질문올립니다

 

" 1. 코스모스팜 회원관리 아바타와 회원등급 숏코드 적용하기 : http://www.cosmosfarm.com/threads/document/15789 "

" 2. 코스모스팜 회원관리 회원등급 숏코드 응용 : http://www.cosmosfarm.com/threads/document/13957 "

 

현재 사이트에 삽입되어있는 숏코드는 [mycred_my_rank show_title=0 show_logo=1]를 적용하여 포인트 등급을 정상적으로 보여주고있습니다

하지만 제가 원하는건 특정유저는 포인트 등급이 아닌 다른 이미지를 보여주고싶습니다

 

회원관리에 없는기능이지만 회원들의 등급별로 마크같은걸 줘서 User Role 플러그인에서 설정한 등급별로 마크가 적용되었으면 좋겠습니다

지금은 포인트에 따른 마크를 표시할수있는 기능뿐이없는데 이게 회원등급과는 상관없이 포인트에 따라 계속 바뀌는 구조라서 회원등급별로 마크를 주고싶습니다

functions.php에 어떤 숏코드를 추가해야 사용자를 필터하여 서로 다른이미지를 보여줄수있는지 궁급합니다

날씨가 많이 추운데 감기 조심하시기 바랍니다~

좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
  • 안녕하세요~^^

    워드프레스 관리자 -> 외모 -> 테마 편집기 -> functions.php 파일에

    아래의 코드를 추가해보세요.

    add_shortcode('user_role_mark', 'my_user_role_mark');
    function my_user_role_mark(){
    	if(wp_get_current_user()->roles[0] == 'administrator'){
    		echo '<img src="이미지 주소1">';
    	}
    	else if(wp_get_current_user()->roles[0] == 'editor'){
    		echo '<img src="이미지 주소2">';
    	}
    	else if(wp_get_current_user()->roles[0] == 'author'){
    		echo '<img src="이미지 주소3">';
    	}
    	else if(wp_get_current_user()->roles[0] == 'contributor'){
    		echo '<img src="이미지 주소4">';
    	}
    	else{
    		echo '<img src="이미지 주소5">';
    	}
    }

    위 코드에서 "이미지 주소1", "이미지 주소2", "이미지 주소3", "이미지 주소4", "이미지 주소5" 부분을

    사이트에서 각 역할별로 적용하고자 하는 이미지의 주소로 수정 후 적용해보세요.

     

    그 다음 원하시는 위치에 아래 숏코드를 추가해보세요.

    [user_role_mark]

    고맙습니다.

  • 답변 감사드립니다

    한가지 문제점이있습니다

    아래와같이 설정을 하였는데 이미지가 제대로 출력이 안되는 현상이 발생하고있는데 해결방법이 없을까요?

     

    1. 현재 적용시켜놓은 코드 (비정상)

    <style>  
    body { background: #fff; }
    .bluetop {
      border-collapse: collapse;
      border-top: 3px solid #168;
    	width: 100%;
    	margin: 5px 0 0 0;
    }
    .bluetop2 {
      border-collapse: collapse;
    	margin: 5px 0 5px 0;
    	width: 100%;
    }  
    .bluetop th {
      color: #168;
      background: #f0f6f9;
    	text-align: center;
    }
    .bluetop th, .bluetop td {
      padding: 5px;
      border: 1px solid #ddd;
    	text-align: center;
    }
    .bluetop th:first-child, .bluetop td:first-child {
      border-left: 0;
    }
    .bluetop th:last-child, .bluetop td:last-child {
      border-right: 0;
    }
    .entry {
    	width: 77px;
    	height: 51px;
    	margin-left:auto;
      margin-right:auto;
    	background-image: url('https://www.w3umc.com/wp-content/uploads/2017/11/etcall1.png');
    }
    .entry2 {
    	width: 77px;
    	height: 51px;
    	margin-left:auto;
      margin-right:auto;
    	background-image: url('https://www.w3umc.com/wp-content/uploads/2017/11/etcall2.png');
    }
    .entryre {
    	text-align: center;
    	padding: 10px 0 0 0;
    }
    </style>
    <center>
    <table class="bluetop">
    	<tr>
    		<th>등급</th>
    		<th>포인트</th>
    	</tr>
    	<tr>
    		<td style="width: 50%">[user_role_mark]</td>
    		<td style="width: 50%">[mycred_my_balance]</td>
    	</tr>
    </table>
    </center>

     

    2. myCRED의 로고를 적용시켜논 코드 (정상)

    <style>  
    body { background: #fff; }
    .bluetop {
      border-collapse: collapse;
      border-top: 3px solid #168;
    	width: 100%;
    	margin: 5px 0 0 0;
    }
    .bluetop2 {
      border-collapse: collapse;
    	margin: 5px 0 5px 0;
    	width: 100%;
    }  
    .bluetop th {
      color: #168;
      background: #f0f6f9;
    	text-align: center;
    }
    .bluetop th, .bluetop td {
      padding: 5px;
      border: 1px solid #ddd;
    	text-align: center;
    }
    .bluetop th:first-child, .bluetop td:first-child {
      border-left: 0;
    }
    .bluetop th:last-child, .bluetop td:last-child {
      border-right: 0;
    }
    .entry {
    	width: 77px;
    	height: 51px;
    	margin-left:auto;
      margin-right:auto;
    	background-image: url('https://www.w3umc.com/wp-content/uploads/2017/11/etcall1.png');
    }
    .entry2 {
    	width: 77px;
    	height: 51px;
    	margin-left:auto;
      margin-right:auto;
    	background-image: url('https://www.w3umc.com/wp-content/uploads/2017/11/etcall2.png');
    }
    .entryre {
    	text-align: center;
    	padding: 10px 0 0 0;
    }
    </style>
    <center>
    <table class="bluetop">
    	<tr>
    		<th>등급</th>
    		<th>포인트</th>
    	</tr>
    	<tr>
    		<td style="width: 50%">[mycred_my_rank show_title=0 show_logo=1]</td>
    		<td style="width: 50%">[mycred_my_balance]</td>
    	</tr>
    </table>
    </center>

  • 안녕하세요.

    아래의 코드처럼 적용해보시겠어요?

    add_shortcode('user_role_mark', 'my_user_role_mark');
    function my_user_role_mark(){
    	if(wp_get_current_user()->roles[0] == 'administrator'){
    		return '<img src="이미지 주소1">';
    	}
    	else if(wp_get_current_user()->roles[0] == 'editor'){
    		return '<img src="이미지 주소2">';
    	}
    	else if(wp_get_current_user()->roles[0] == 'author'){
    		return '<img src="이미지 주소3">';
    	}
    	else if(wp_get_current_user()->roles[0] == 'contributor'){
    		return '<img src="이미지 주소4">';
    	}
    	else{
    		return '<img src="이미지 주소5">';
    	}
    }

    위에서 안내해드린 코드에서 echoreturn으로 교체해주시면 됩니다.

    고맙습니다.

  • 답변 감사합니다

    정상출력됩니다

    정말 감사드립니다

좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기