Support

Account

Forum Replies Created

  • I added a standard location rule only show ACF when post_type is equal to ‘presentation’.

    I think that is the way it should work no ?

    Dave

  • The transporter can edit ‘presentacion’, the other one is for future use….

    DAve

  • Hello John,

    Yes the point is that I want a user (transporter) to be capable of only editing his presentation, but of course not the ones of other users.

    Thats why I created separate user Roles and have to deny them other capabilities.
    But to my surprise every thing worked well when I’m connected as an administrator, but when I connect as a Transporter, suddenly the ACF fields are gone and I’m left with only the basic post fields.

    Searching in forum and googling a bit I found out that any user has to have capability: edit_others_xxxx activated (where xxxx in this case would be ‘presentaciones’) to be able to use ACF fields when editing post.

    But of course this gives them the posability to edit the presentations of other users too..

    Dave

  • If you want to see it work I would have to send you the exported fieldgroup otherwise you can’t see the ACF fields.

    To use and see the ACF fields, a user Role needs to have the ‘edit_other_posts’ capability active. (accoring to posts I read in your forum)

    And thats exactly a capability that I don’t want to give them.

    Dave

  • The point is that yes you can edit, but not having the acf fields…

    When I test in another domain, without any plugins only acf and my function file it happens the same…

    Of course I need to export the field group too to be able to see it well

    But as I said before I think my solution is in taking the editing to the frontend where I see it works well..

    Dave

  • This works for me, the custom role can create and modify his ‘presentacion’ but not the ones of other users…
    But ACF needs a capability ‘edit_others_posts’ or in this case ‘edit_others_presentaciones’ to work, if the role doesn’t have this capability the ACF fields don’t work. ( in backend).

    But meanwhile I think I found a solution in making frontend forms to edit the ‘presentaciones’, I’ve seen that in the frontend the ACF fields works fine without these capabilities.

    
    <?php 
      
      // Register Presentacion Post Type
      function presentacion_post_type() {
        $labels = array(
          'name' => _x( 'Presentaciones', 'Post Type General Name', 'text_domain' ),
          'singular_name' => _x( 'Presentacion', 'Post Type Singular Name', 'text_domain' ),
          'menu_name' => __( 'Presentacion', 'text_domain' ),
          'name_admin_bar' => __( 'Presentaciones', 'text_domain' ),
          'parent_item_colon' => __( 'Presentacion padre:', 'text_domain' ),
          'all_items' => __( 'Todos los Presentaciones', 'text_domain' ),
          'add_new_item' => __( 'Añadir nueva Presentacion', 'text_domain' ),
          'add_new' => __( 'Añadir nueva', 'text_domain' ),
          'new_item' => __( 'Nueva Presentacion', 'text_domain' ),
          'edit_item' => __( 'Editar Presentacion', 'text_domain' ),
          'update_item' => __( 'Actualizar Presentacion', 'text_domain' ),
          'view_item' => __( 'Ver Presentacion', 'text_domain' ),
          'search_items' => __( 'Buscar Presentacione', 'text_domain' ),
          'not_found' => __( 'Presentacion no encontrada', 'text_domain' ),
          'not_found_in_trash' => __( 'Presentacion no en papelera', 'text_domain' ),
        );
        $rewrite = array(
          'slug' => 'transportista',
          'with_front' => true,
          'pages' => true,
          'feeds' => true,
        );
        $capabilities = array(
          'edit_post' => 'edit_presentacion',
          'edit_posts' => 'edit_presentaciones',
          'read_post' => 'read_presentacion',
          'delete_post' => 'delete_presentacion',
          'edit_others_posts' => 'edit_others_presentaciones',
          'publish_posts' => 'publish_presentaciones',
          'read_private_posts' => 'read_private_presentaciones',
        );
        $args = array(
          'label' => __( 'Presentacion', 'text_domain' ),
          'description' => __( 'Presentacion de transportista', 'text_domain' ),
          'labels' => $labels,
          'supports' => array(
            'title',
            'editor',
            'excerpt',
            'author',
            'thumbnail',
            'comments',
            'custom-fields'
          ),
          'taxonomies' => array( 'provincia' ),
          'hierarchical' => false,
          'public' => true,
          'show_ui' => true,
          'show_in_menu' => true,
          'menu_position' => 5,
          'menu_icon' => 'dashicons-id',
          'show_in_admin_bar' => true,
          'show_in_nav_menus' => true,
          'can_export' => true,
          'has_archive' => true,
          'exclude_from_search' => false,
          'publicly_queryable' => true,
          'rewrite' => $rewrite,
          'capabilities' => $capabilities,
        );
        register_post_type( 'presentacion', $args );
      }
      add_action( 'init', 'presentacion_post_type', 0 );
      
      // Add a custom user role
      $result = add_role( 'transporter', __('Transporter' ), array( 'read' => true, ) );
      $result = add_role( 'cliente', __('Cliente' ), array( 'read' => true, ) );
      
      // add capabilities to roles editor and administrator
      global $wp_roles;
      $capabilities = array(
        'edit_presentacion',
        'edit_presentaciones',
        'read_presentacion',
        'delete_presentacion',
        'edit_others_presentaciones',
        'publish_presentaciones',
        'read_private_presentaciones',
        'edit_transporte',
        'edit_transportes',
        'read_transporte',
        'delete_transporte',
        'edit_others_transportes',
        'publish_transportes',
        'read_private_transportes',
        'manage_transportype',
        'edit_transportype',
        'delete_transportype',
        'assign_transportype',
        'manage_provincia',
        'edit_provincia',
        'delete_provincia',
        'assign_provincia'
      );
      $role = get_role( 'administrator' );
      foreach( $capabilities as $cap ) {
        $role->add_cap( $cap );
      }
      $role = get_role( 'editor' );
      foreach( $capabilities as $cap ) {
        $role->add_cap( $cap );
      }
      $transcapabilities = array( 
        'edit_presentacion',
        'edit_presentaciones',
        'read_presentacion',
        'upload_files',
        'assign_provincia',
        'assign_transportype',
        'edit_others_posts'
      );
      $role = get_role( 'transporter');
      foreach( $transcapabilities as $cap ) {
        $role->add_cap( $cap );
      }
      $notranscapabilities = array(
        'edit_posts',
        'edit_pages',
        'create_posts',
        'manage_categories',
        'publish_posts',
        'edit_themes',
        'install_plugins',
        'update_plugin',
        'update_core',
        'delete_presentacion',
        'edit_others_presentaciones',
        'publish_presentaciones',
        'read_private_presentaciones',
        'delete_transporte',
        'edit_others_transportes',
        'publish_transportes',
        'read_private_transportes'
      );
      foreach( $notranscapabilities as $cap ) {
        $role->remove_cap( $cap );
      }
      $clientcapabilities = array(
        'edit_transporte',
        'edit_transportes',
        'read_transporte',
        'assign_provincia',
        'assign_transportype'
      );
      $role = get_role( 'cliente' );
      foreach( $clientcapabilities as $cap ) {
        $role->add_cap( $cap );
      }
      $noclientcapabilities = array(
        'edit_posts',
        'edit_pages',
        'edit_others_posts',
        'create_posts',
        'manage_categories',
        'publish_posts',
        'edit_themes',
        'install_plugins',
        'update_plugin',
        'update_core',
        'edit_presentacion',
        'edit_presentaciones',
        'read_presentacion',
        'delete_presentacion',
        'edit_others_presentaciones',
        'publish_presentaciones',
        'read_private_presentaciones',
        'delete_transporte',
        'edit_others_transportes',
        'publish_transportes',
        'read_private_transportes'
      );
      foreach( $noclientcapabilities as $cap ) {
        $role->remove_cap( $cap );
      }
      
    ?>
    
  • I mean the google maps field

    sorry

Viewing 7 posts - 1 through 7 (of 7 total)