Support » Plugin: amr users » unable to use both “Link Type” & “Before & After” in same list

  • I set up Link Type for “Last name” field to link to “bbpress user profile page”; and “Email” field as “mailto:”. They both worked fine until I use the “Before & After” feature on the “Id” field in the same list…. then all links in the list disappeared… Getting rid of the “Before & After” entries for the “Id” field, the Link Type links return to normal.

    It seems to me that the “Link Type” feature needs to use the “Id” field to generate the required link.

    Is it possible to keep the “Before & After” feature for the User ID field, while making the generic “Link Type” to work? Or is it possible to have the Id field include in the list more than once, so we can use them (by way of “Before & After”) to create customized links pointing to various user specific pages as needed?

    I am using AMR USERS 4.7 + AMR USERS PLUS 3.2
    Thank you for you help and the plug-ins

    • This topic was modified 3 years, 1 month ago by chinkchink.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author anmari

    (@anmari)

    Have you considered using css like the before pseudo element to insert your before/after content? eg: https://css-tricks.com/almanac/properties/c/content/
    This would get around that issue.

    Before and After fields were originally created for folks who wanted to have them actually included in the csv data, which means that the before & after were inserted as part of the value, NOT added at format time.

    So as you noticed, because of the cacheing – they’re part of the value so yes it would mess up using the original value.

    While I do have plans for a complete rewrite to get away from the cacheing, and therefore also this problem, it is risky for compatibility with the ways people are using, so will be a while before it’s available.

    • This reply was modified 3 years, 1 month ago by anmari.

    Thanks for the reply.
    If it was only plain text I needed to add to the field value, I agree, CSS pseudo classes are better solutions then using “Before & After”. But I needed to generate a unique link using the user id as part of an URL parameter, something like this:
    <a href=www.webdomain.com/userreport.php?uid=2222>View this user's report</a>
    where 2222 is the user id.

    CSV export is not a concern for me either, not in this particular listing anyway.

    I understand that I am not using “Before & After” as it was intended, but see no other way to accomplish what I need. Do you have other suggestions on how to generate the link as described above?

    Thanks much

    Plugin Author anmari

    (@anmari)

    Sure, you could write a little site specific add-on plugin with a bit of code to either write special formatting routine based on a field name, or add your own linktype. Either would be much better because you could then add a href title, use an image etc

    These notes may help

    https://wpusersplugin.com/2645/format-any-field-any-way-you-wish/

    https://wpusersplugin.com/3809/format-a-field-as-a-link/

    https://wpusersplugin.com/2860/adding-a-link-to-user-list-field/

    Thanks for the tips. I think I am almost there, just need a few more pointers:

    (1) I was able to create one custom Link Type in my site-specific-plug-in, using the sample code from the “example-site-specific2.0” file, everything works as expected. But how do I create a second one?
    After I tried to create a second Link Type, both the first and the second one showed up in the Link Type dropdown as expected, but the second URL overrode the URL of the first one, making both types linking to the same page.

    (2) When I tried to use the “formatting routine” in my site-specific-plug-in, nothing happened, looks like the code did not run at all… may be missing a hook?
    For testing purpose, I simply copied your sample code on https://wpusersplugin.com/2645/format-any-field-any-way-you-wish/ and paste it in my site-specific-plug-in php page, but the “Nice Name” in my list did not turn into a link. Then I tried pasting your code in “amr-users-plus-pluggable.php” (just for a quick test, I know I should not alter this file) and the formatting for “Nice Name” was applied as expected, it was displayed as a link to the user’s webpage in the list.

    (3) Is it possible to apply “formatting routine” to a field that also uses Link Type?

    (4) Any suggestions on how to create multiple links (to different landing pages) that require using “User ID” in the URL parameters, in a single user record?

    Really appreciate your help

    Thanks

    Plugin Author anmari

    (@anmari)

    Hi – in reverse order

    4) You can use any field to have a link behind and/or create your own ‘dummy’ fields. See filters https://wpusersplugin.com/2940/filters/ In your case if you just use a format routine, you could return a series of links as the ‘format’ for the one field if you wanted. It’s all just html.

    3) No – can’t have both. The linktype is a ‘format’ in a sense. you would just include the hyperlink in the format routine. The user object is available to the format routine .https://wpusersplugin.com/2645/format-any-field-any-way-you-wish/

    2) Take off any linktypes from the field you are formatting. Those get checked first, so formatting wont’ kick in if a linktype has been applied. Make sure you have named the formatting routine correctly relative to the field and check that your code is actually returning something, and of course that the little addon is active.

    1) if you adding more than 1 linktype in the ‘add link type’ routine, make sure that they are named differently, and then in the link type function – check which linktype has been passed and return appropriate function. I’ll update the example plugin with some more samples.

    EG:

    
    Function amr_add_link_type_functions (	$linktype, $u, $field ) {// the current value and the user data and the field the link is on ) 
    	if ($linktype = 'detailpage') { $url = 'your url';		
    	}
    	elseif ($linktype = 'otherdetailpage') { 
    		$url = 'http://your other special url with?id='.$u->ID.' etc' ;
    	}
    	return ($url);
    }
    
    function amr_add_link_types ($linktypes) { 
    	$linktypes['detailpage'] 	= __('detail page', 'amr_users');
    	$linktypes['otherdetailpage'] 	= __('other detail page', 'amr_users');
    	return ($linktypes);
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘unable to use both “Link Type” & “Before & After” in same list’ is closed to new replies.