- This topic has 1 reply, 2 voices, and was last updated 2 years, 4 months ago by .
-
Topic
-
Hello Anh,
So I’m trying to create a relationship between users as mentioned on this MB relationship plugin “Supports creating reciprocal relationships (posts-posts, users-users, …).” based on their roles.
let’s say there is a “student” and “teacher”. I want to create a reciprocal relationship between them, saying “student” can choose “teacher” and vice-versa. with a single field.
For now, I tried this code.
add_action( 'mb_relationships_init', function () { MB_Relationships_API::register( array( 'id' => 'stud_to_teach', 'from' => array( 'object_type' => 'user', 'role__in' => 'student', 'meta_box' => array( 'title' => 'Manages', 'field_title' => 'Select Users', ), ), 'to' => array( 'object_type' => 'user', 'user_role' => 'teacher', 'meta_box' => array( 'title' => 'Manages users', 'field_title' => 'Select Users', ), ), ) ); } );
what it’s doing is creating 2 fields. and allowing me to add more, but it’s showing every type of users. am I using the key
user_role
wrong? what should be the correct key?also I’m struggling with the logic of
if logged_in_user is student then show only teacher. And if logged_in_user is teacher then show only student.
- You must be logged in to reply to this topic.