Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 16 through 30 (of 39 total)
  • Author
    Posts
  • in reply to: Relationships and capabilities #41552
    OlivierOlivier
    Participant

    EDIT: as for the New > Relationships submenu, a Contributor cannot actually create a new relationship. It leads to a page with the only option to add a Title and Submit for Review. So at least they're not able to create new relationships -- but it's also a completely useless and potentially confusing menu, so I'd love to remove it

    in reply to: Relationship working on Author page but not Post #41548
    OlivierOlivier
    Participant

    Sure thing, in fact I can paste the generated PHP code for the relationship:

    <?php
    add_action( 'mb_relationships_init', 'your_prefix_function_name' );
    
    function your_prefix_function_name() {
        MB_Relationships_API::register( [
            'id'   => 'user-provider',
            'from' => [
                'object_type'   => 'user',
                'post_type'     => 'licensee',
                'taxonomy'      => 'category',
                'empty_message' => 'Not affiliated with a Provider',
                'admin_column'  => [
                    'position' => 'after title',
                    'title'    => 'Affiliation',
                    'link'     => 'view',
                ],
                'meta_box'      => [
                    'title'   => 'Provider you\'re affiliated with',
                    'context' => 'normal',
                    'style'   => 'seamless',
                ],
            ],
            'to'   => [
                'object_type'  => 'post',
                'post_type'    => 'licensee',
                'admin_column' => [
                    'position' => 'after title',
                    'title'    => 'Affiliated',
                    'link'     => 'view',
                ],
                'meta_box'     => [
                    'title'    => 'User accounts associated with this licensee',
                    'context'  => 'normal',
                    'priority' => 'high',
                ],
                'field'        => [
                    'name' => 'Affiliated Licensee',
                ],
            ],
        ] );
    }

    But if you want a screenshot from the UI here is one https://imgur.elightup.com/vYJ3QdK.png

    in reply to: Relationship working on Author page but not Post #41532
    OlivierOlivier
    Participant

    Views already offers the {{ author.ID }} variable, why can't I use that? I tried it and it makes the whole page break.

    That said, to verify the code is working in the first place I replaced UserID with the value 7 (user ID of the author of a post I'm testing the View on) and it's still not showing anything...

    Are you sure the code you provided is sound?

    in reply to: Relationship working on Author page but not Post #41521
    OlivierOlivier
    Participant

    Edit: you'll see post-type declared as licensee above instead of provider. Ignore that - I was trying it because I use a slug rewrite. But the result is the same with both.

    in reply to: Relationship working on Author page but not Post #41520
    OlivierOlivier
    Participant

    Peter,

    I appreciate your answer, unfortunately it's not working.

    Would it be an issue with from: UserID ? I wonder if it should be something else since I need providers connected to the post author, not the current logged in user visiting the page.

    Here is the View I created with your input:

    {% set args = { post_type: 'licensee', relationship: {
    	id: 'user-provider',
    	from: userID
    } } %}
    {% set posts = mb.get_posts( args ) %}
    {% for post in posts %}
    	
    <a href="{{ post.url }}">
    <div class="mb-container related-provider provider-related-to-user">
    
    <div class="provider-logo">
    {% set field = attribute( post, '_thumbnail_id' ) %}
    
    {% for item in field %}
    	<img src="{{ item.medium.url }}" alt="{{ item.medium.alt }}">
    {% endfor %}
    </div>
    
    <div class="provider-name">
    <span>{{ post.title }}</span>
    </div>
    
    </div>
    </a>
    
    {% endfor %}
    OlivierOlivier
    Participant

    I was looking to do the same thing and the code above, although adapted to my variables, doesn't work. Was anyone ever able to make this work? I have yet to find a post on this forum where someone says they've been able pull data from a relationship into a query.

    in reply to: Exclude custom post type from taxonomy archives #41488
    OlivierOlivier
    Participant

    "Exclude from search" worked! thank you

    in reply to: Exclude custom post type from taxonomy archives #41472
    OlivierOlivier
    Participant

    Hi Peter,

    I'm not sure I understand your question. The taxonomy archive is in the typical locations automatically created by WordPress for any taxonomy, i.e. http://www.site.com/taxonomy_name_slug/taxonomy_term_slug

    I have already disabled archives for the CPT in question, and that works fine. But that CPT still shows up on the archives of the taxonomy (along with another post types), and I would like this specific CPT *not* to appear in the archives of that taxonomy.

    Does it make sense?

    in reply to: Disable archive page for chosen taxonomy? #41447
    OlivierOlivier
    Participant

    Nevermind, I found how to do it by checking off "Public queryable" in the Advanced options for that taxonomy.

    OlivierOlivier
    Participant

    Thanks Peter, but as far as I understand, that function is a normal WordPress function, not specific to GenerateBlocks - or am I wrong?

    I'm not understanding why this code is not working:

    add_filter( 'render_block', function( $block_content, $block ) {
        if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'licensee-name' ) !== false ) {
    		$myreplace1 = 'placeholder';
    		
    		$hol_licensee_name = MB_Relationships_API::get_connected( [
    		'id'   => 'licensee-events',
    		'to' => get_the_ID(),
    	] );
    					
            $block_content = str_replace( $myreplace1, $hol_licensee_name , $block_content );
     
        }
     
        return $block_content;
    }, 10, 2 );

    Can you help?

    in reply to: Filter query loop by Relationship #40111
    OlivierOlivier
    Participant

    Peter, it works thank you so much! I've been struggling with this for weeks!

    Can you clarify what you mean by "You can pass object ID or full object"? I understand object ID, but what is "full object"? Do you mean the object ID, and any content field within it?

    in reply to: Customizing TinyMCE in Wysiwyg Editor #40098
    OlivierOlivier
    Participant

    Ha! That's exactly what I needed - I figured it out thank you!

    Here is an example screenshot for anyone looking for something like this in the future: https://imgur.elightup.com/ABmJ0xy.png

    in reply to: Filter query loop by Relationship #40076
    OlivierOlivier
    Participant

    Hi Peter,

    I'm not sure how to find/share the code for the query, it is generated by the GenerateBlocks Pro plugin. That's why I don't know how to pass relationship parameters to it, and the documentation is not helping me (I see the documentation, I just don't know how to use it for my use-case).

    However I can share the code I'm currently using to filter the query based on a custom field (using Metabox' "Post" custom field to mimic a relationship):

    add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
       
        if ( ! is_admin() &&
            ! empty( $attributes['className'] ) &&
            strpos( $attributes['className'], 'only-provider-events' ) !== false
        ) {
            return array_merge( $query_args, array(
                'meta_query' => array( 
            array(
                'key' => 'event_host', 
                'value' => get_the_ID(), 
                'compare' => '=',
            )
        )
            ) );
        }
     
        return $query_args;
     
    }, 10, 2 );

    Can I tweak this code snippet to pass relationship parameters?

    If I can get this to work, I'll be happy to go publish the solution on the GeneratePress/GenerateBlocks forums, as I know I'm not the only one struggling with this.

    in reply to: Customize Relationships Shortcode? #40054
    OlivierOlivier
    Participant

    Thank you. And if I want to filter a Query Loop by some fields of a related post, would I use the code described in https://docs.metabox.io/extensions/mb-relationships/#post-archive ?

    in reply to: Customize Relationships Shortcode? #40048
    OlivierOlivier
    Participant

    Thank you Peter, even just that is incredibly more useful than the documentation.

    And to clarify, I would put this code in my template file, right?

Viewing 15 posts - 16 through 30 (of 39 total)