jarvo1980
Forum Replies Created
-
Forum: Plugins
In reply to: [User Role Editor] Set second role automaticallySorry, I’ve now resolved this issue with the following code:
if ( current_user_can( 'basic' )) { function add_secondary_role( $user_id ) { $user_id = get_current_user_id(); $user = get_user_by('id', $user_id); $user->add_role('author'); } add_action( 'add_subscriber_role', 'add_secondary_role', 10, 2 ); do_action( 'add_subscriber_role', $user_id); }Thanks for your help!
Forum: Plugins
In reply to: [User Role Editor] Set second role automaticallyApologies, I missed a line out:
if ( current_user_can( 'basic' )) { add_action( 'user_register', 'add_secondary_role', 10, 1 ); function add_secondary_role( $user_id ) { $user = get_user_by('id', $user_id); $user->add_role('author'); } }However, that doesn’t work either
Forum: Plugins
In reply to: [User Role Editor] Set second role automaticallyHi Vladimir,
I had it wrapped in the following:
if ( current_user_can( 'basic' )) { function add_secondary_role( $user_id ) { if (current_user_can('basic')) { $user = get_user_by('id', $user_id); $user->add_role('author'); } } }Is there a better way of doing this or is this incorrect? Basically, I only want to apply this IF a user has a set capability (which is added via WooCommerce Groups)
Thanks
Forum: Plugins
In reply to: [User Role Editor] Set second role automaticallyForgot to add my code (sorry):
function add_secondary_role( $user_id ) { if (current_user_can('basic')) { $user = get_user_by('id', $user_id); $user->add_role('author'); } }So what I’d like to do, if a user has the capability of ‘basic’, it automatically adds the second role Author
However, with that in my functions file, it simply won’t work.
I can only get a second role to add when you do this by manually editing the user
Thanks
Forum: Plugins
In reply to: [User Role Editor] Set second role automaticallyHi Vladimir,
I’ve predefined the customer role via WooCommerce
It’s not a multisite
What I’m trying to achieve is add a second role if the user has a particular capability, but can’t see how to do that.
Any help is much appreciated!
Forum: Plugins
In reply to: [User Role Editor] Set second role automaticallyThanks for the reply.
I’m using Version 4.19.3 which seems to be the latest one
I assume the code (above) can just go in the functions file? Surely that should work even if the plugin doesn’t?
Forum: Plugins
In reply to: [User Role Editor] Set second role automaticallyThanks Vladimir
Sadly that doesn’t work.
Whenever a new user signs up, the 2nd role isn’t being added automatically
I even tried the code from your website:
add_action( 'user_register', 'add_secondary_role', 10, 1 ); function add_secondary_role( $user_id ) { $user = get_user_by('id', $user_id); $user->add_role('author'); }However, that doesn’t seem to work either
Any further help is much appreciated!
Forum: Plugins
In reply to: [Query Multiple Taxonomies] multiple taxonomies queryThanks for the reply scribu I think I may have to opt for custom code instead 🙁
Forum: Fixing WordPress
In reply to: Order by issueThink I’ve sussed it with
'orderby' =>'menu_order',Forum: Fixing WordPress
In reply to: link a page to multiple categoriesThanks keesiemeijer, I think I’ve found something which will help:
It seems to do what I want (I believe). Just trying to change the_category to output as follows now:
- <span>» Link</span>
There’s always something, sigh…
Forum: Fixing WordPress
In reply to: Author Page Help – Multiple Authors & There postsOk, I’ve altered the loop to
<?php $numposts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status='publish' AND post_type='post' AND post_author = " . $curauth->ID . " ORDER BY post_modified LIMIT 3"); ?> <ul> <?php foreach ($numposts as $numpost) { $link = get_permalink( $numpost->ID ); echo '<li><a href="' . $link . '">'.$numpost->post_title."</a></li>"; } ?> </ul>It now works
Forum: Fixing WordPress
In reply to: Category only shows when logged inSorry to bump but I’m sadly struggling with this and cant see why it’s not showing a category unless logged in.
TIA
Forum: Fixing WordPress
In reply to: Category only shows when logged inHi,
I’m still not having any joy with this. Am I doing something really wrong or is it a common issue?
Thanks
Forum: Fixing WordPress
In reply to: Anchor Link Issued’oh! Pretty obvious really 🙁 Sorry!
Thanks for the help though, very much appreciated!
Forum: Fixing WordPress
In reply to: Anchor Link IssueOddly removing the image worked. Why’s that? Sorry for the questions but your help is much appreciated!